@@ -5,60 +5,63 @@ Golang implementation of [docopt](http://docopt.org/) 0.6.1+fix
5
5
6
6
## Installation
7
7
8
- import "github.com/kbatten/docopt.go" and then run ` go get `
8
+ import "github.com/kbatten/docopt.go" and then run ` go get ` .
9
9
10
10
## API
11
11
12
+ * These may be updated because it seems like a cumbersome way to get around optional parameters*
12
13
14
+ ``` go
15
+ func docopt.Parse (doc string , argv []string , help bool , version string , optionsFirst bool )
16
+ (args map [string ]interface {}, output string , err error )
13
17
```
14
- args, output, err := docopt.Parse(doc string, argv []string, help bool, version string, optionsFirst bool)
15
-
16
18
- parse and return a map of args, output and all errors
17
- ```
18
19
20
+ ``` go
21
+ func docopt.ParseEasy (doc string )
22
+ args map [string ]interface {}
19
23
```
20
- args := docopt.ParseEasy(doc string)
21
-
22
24
- parse just doc and return a map of args
23
25
- handle all printing and non-fatal errors
24
26
- panic on fatal errors
25
27
- exit on user error or help
26
- ```
27
-
28
- ```
29
- args, err := docopt.ParseQuiet(doc string, argv []string, help bool, version string, optionsFirst bool)
30
-
31
- - parse and return a map of args and fatal errors
32
- - handle printing of help
33
- - exit on user error or help
34
- ```
35
28
29
+ ``` go
30
+ func docopt.ParseLoud (doc string , argv []string , help bool , version string , optionsFirst bool )
31
+ args map [string ]interface {}
36
32
```
37
- args := docopt.ParseLoud(doc string, argv []string, help bool, version string, optionsFirst bool)
38
33
39
34
- parse and return a map of args
40
35
- handle all printing and non-fatal errors
41
36
- panic on fatal errors
42
37
- exit on user error or help
38
+
39
+ ``` go
40
+ func docopt.ParseQuiet (doc string , argv []string , help bool , version string , optionsFirst bool )
41
+ (args map [string ]interface {}, err error )
43
42
```
44
43
44
+ - parse and return a map of args and fatal errors
45
+ - handle printing of help
46
+ - exit on user error or help
47
+
45
48
### arguments
46
49
47
- ` doc ` usage string based on docopt language
50
+ ` doc ` , usage string based on docopt language.
48
51
49
- ` argv ` optional argument vector. set to ` nil ` to use os.Args
52
+ ` argv ` , optional argument vector. set to ` nil ` to use os.Args.
50
53
51
- ` help ` set to ` true ` to have docopt automatically handle ` -h ` and ` --help `
54
+ ` help ` , set to ` true ` to have docopt automatically handle ` -h ` and ` --help ` .
52
55
53
- ` version ` set to a non-empty string that will automatically be shown with ` --version `
56
+ ` version ` , set to a non-empty string that will automatically be shown with ` --version ` .
54
57
55
- ` optionsFirst ` set to ` true ` to disallow mixing options and positional arguments
58
+ ` optionsFirst ` , set to ` true ` to disallow mixing options and positional arguments.
56
59
57
60
### return values
58
61
59
- ` args ` map[ string] interface{}. interface{} can be ` bool ` , ` int ` , ` string ` , ` []string `
62
+ ` args ` , map[ string] interface{}. interface{} can be ` bool ` , ` int ` , ` string ` , ` []string ` .
60
63
61
- ` output ` help output that would normally be displayed by the other ` docopt.Parse* ` functions.
64
+ ` output ` , help output that would normally be displayed by the other ` docopt.Parse* ` functions.
62
65
63
66
` err `
64
67
@@ -80,12 +83,12 @@ func main() {
80
83
usage := ` Naval Fate.
81
84
82
85
Usage:
83
- naval_fate.py ship new <name>...
84
- naval_fate.py ship <name> move <x> <y> [--speed=<kn>]
85
- naval_fate.py ship shoot <x> <y>
86
- naval_fate.py mine (set|remove) <x> <y> [--moored|--drifting]
87
- naval_fate.py -h | --help
88
- naval_fate.py --version
86
+ naval_fate ship new <name>...
87
+ naval_fate ship <name> move <x> <y> [--speed=<kn>]
88
+ naval_fate ship shoot <x> <y>
89
+ naval_fate mine (set|remove) <x> <y> [--moored|--drifting]
90
+ naval_fate -h | --help
91
+ naval_fate --version
89
92
90
93
Options:
91
94
-h --help Show this screen.
@@ -101,6 +104,8 @@ Options:
101
104
102
105
## Testing
103
106
104
- All tests from the python version have been implemented pass
107
+ All tests from the python version have been implemented and all are passing.
108
+
109
+ New language agnostic tests have been added to ` test_golang.docopt ` .
105
110
106
- To run them use ` go test `
111
+ To run them use ` go test ` .
0 commit comments