When a non-option line comes after the Options: declaration, parsing fails in weird ways. Not only are options missing, but -h and --help are now split. This doesn't happen at try.docopt.org.
Repro
Start with the options shortcut example
package main
import (
"fmt"
"github.com/docopt/docopt-go"
)
func main() {
usage := `Example of program which uses [options] shortcut in pattern.
Usage:
options_shortcut_example [options] <port>
options_shortcut_example -h | --help
Options:
-h --help show this help message and exit
--version show version and exit
-n, --number N use N as a number
-t, --timeout TIMEOUT set timeout TIMEOUT seconds
--apply apply changes to database
-q operate in quiet mode`
arguments, _ := docopt.Parse(usage, nil, false, "1.0.0rc2", false)
fmt.Println(arguments)
}
Modify as such
Options:
+These are things
-h --help show this help message and exit
Expected Behavior
$ go run options_shortcut_example.go --help
map[<port>:<nil> --help:true --version:false --number:<nil> --timeout:<nil> --apply:false -q:false]
Actual Behavior
$ go run options_shortcut_example.go --help
map[<port>:<nil> -h:false --help:true]
Description
When a non-option line comes after the
Options:
declaration, parsing fails in weird ways. Not only are options missing, but-h
and--help
are now split. This doesn't happen at try.docopt.org.Repro
Expected Behavior
Actual Behavior