Skip to content

Commit

Permalink
cleanup README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kbatten committed Aug 30, 2013
1 parent 31e3220 commit add161b
Showing 1 changed file with 36 additions and 31 deletions.
67 changes: 36 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,63 @@ Golang implementation of [docopt](http://docopt.org/) 0.6.1+fix

## Installation

import "github.com/kbatten/docopt.go" and then run `go get`
import "github.com/kbatten/docopt.go" and then run `go get`.

## API

*These may be updated because it seems like a cumbersome way to get around optional parameters*

``` go
func docopt.Parse(doc string, argv []string, help bool, version string, optionsFirst bool)
(args map[string]interface{}, output string, err error)
```
args, output, err := docopt.Parse(doc string, argv []string, help bool, version string, optionsFirst bool)
- parse and return a map of args, output and all errors
```

``` go
func docopt.ParseEasy(doc string)
args map[string]interface{}
```
args := docopt.ParseEasy(doc string)
- parse just doc and return a map of args
- handle all printing and non-fatal errors
- panic on fatal errors
- exit on user error or help
```

```
args, err := docopt.ParseQuiet(doc string, argv []string, help bool, version string, optionsFirst bool)
- parse and return a map of args and fatal errors
- handle printing of help
- exit on user error or help
```

``` go
func docopt.ParseLoud(doc string, argv []string, help bool, version string, optionsFirst bool)
args map[string]interface{}
```
args := docopt.ParseLoud(doc string, argv []string, help bool, version string, optionsFirst bool)

- parse and return a map of args
- handle all printing and non-fatal errors
- panic on fatal errors
- exit on user error or help

``` go
func docopt.ParseQuiet(doc string, argv []string, help bool, version string, optionsFirst bool)
(args map[string]interface{}, err error)
```

- parse and return a map of args and fatal errors
- handle printing of help
- exit on user error or help

### arguments

`doc` usage string based on docopt language
`doc`, usage string based on docopt language.

`argv` optional argument vector. set to `nil` to use os.Args
`argv`, optional argument vector. set to `nil` to use os.Args.

`help` set to `true` to have docopt automatically handle `-h` and `--help`
`help`, set to `true` to have docopt automatically handle `-h` and `--help`.

`version` set to a non-empty string that will automatically be shown with `--version`
`version`, set to a non-empty string that will automatically be shown with `--version`.

`optionsFirst` set to `true` to disallow mixing options and positional arguments
`optionsFirst`, set to `true` to disallow mixing options and positional arguments.

### return values

`args` map[string]interface{}. interface{} can be `bool`, `int`, `string`, `[]string`
`args`, map[string]interface{}. interface{} can be `bool`, `int`, `string`, `[]string`.

`output` help output that would normally be displayed by the other `docopt.Parse*` functions.
`output`, help output that would normally be displayed by the other `docopt.Parse*` functions.

`err`

Expand All @@ -80,12 +83,12 @@ func main() {
usage := `Naval Fate.
Usage:
naval_fate.py ship new <name>...
naval_fate.py ship <name> move <x> <y> [--speed=<kn>]
naval_fate.py ship shoot <x> <y>
naval_fate.py mine (set|remove) <x> <y> [--moored|--drifting]
naval_fate.py -h | --help
naval_fate.py --version
naval_fate ship new <name>...
naval_fate ship <name> move <x> <y> [--speed=<kn>]
naval_fate ship shoot <x> <y>
naval_fate mine (set|remove) <x> <y> [--moored|--drifting]
naval_fate -h | --help
naval_fate --version
Options:
-h --help Show this screen.
Expand All @@ -101,6 +104,8 @@ Options:

## Testing

All tests from the python version have been implemented pass
All tests from the python version have been implemented and all are passing.

New language agnostic tests have been added to `test_golang.docopt`.

To run them use `go test`
To run them use `go test`.

0 comments on commit add161b

Please sign in to comment.