Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a line follows Options: declaration, options don't parse correctly #50

Open
ghost opened this issue Jan 3, 2018 · 0 comments
Open

Comments

@ghost
Copy link

ghost commented Jan 3, 2018

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

  1. 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)
}
  1. 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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants