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

Inconsistencies in ambiguity resolution #19

Open
gdetrez opened this issue Jul 13, 2015 · 1 comment
Open

Inconsistencies in ambiguity resolution #19

gdetrez opened this issue Jul 13, 2015 · 1 comment

Comments

@gdetrez
Copy link

gdetrez commented Jul 13, 2015

While filing up #18, I found a small inconsistency in the way ambiguities are resolved.
According to docopt.org:

Note, writing --input ARG (opposed to --input=ARG) is ambiguous, meaning it is not possible to tell whether ARG is option's argument or positional argument. In usage patterns this will be interpreted as option with argument only if option's description (covered below) for that option is provided. Otherwise it will be interpreted as separate option and positional argument.

So, if you take the following

Usage:
  test --input ARG

and call it with --input foo you'd expect:

fromList [(LongOption "input",Present),(Argument "ARG",Value "foo")]

but you get

fromList [(LongOption "input",Value "foo")]

Even providing the correct option description doesn't get the intended behavior:

Usage:
  test --input ARG
Options:
  --input
$ test --input foo
fromList [(LongOption "input",Value "foo")]

Disambiguating it the other way gives you something even stranger:

Usage:
  test --input ARG
Options:
  --input ARG
$ test --input foo
fromList [(LongOption "input",Value "foo"),(Argument "ARG",NoValue)]
@gdetrez
Copy link
Author

gdetrez commented Jul 13, 2015

I've played a bit more with ambiguous options, there are similar problems with short options:

Usage:
  foo -f ARG
$ foo -f bar
fromList [(ShortOption 'f',Value "bar")]
# Expected: fromList [(ShortOption 'f',Present),(Argument "ARG",Value "bar")]

Usage:
  foo -f ARG
Options:
  -f
$ foo -f bar
fromList [(ShortOption 'f',Value "bar")]
# Expected: fromList [(ShortOption 'f',Present),(Argument "ARG",Value "bar")]

$ foo
fromList [(ShortOption 'f',NoValue)] 
# Expected: Usage: ...

Usage:
  foo -f ARG
Options:
  -f ARG
foo -f bar
fromList [(ShortOption 'f',Value "bar"),(Argument "ARG",NoValue)]
# Expected: fromList [(ShortOption 'f',Value "bar")]

with

Usage:
  foo -fARG
Options:
  -fARG
$ foo -fbar
Usage:
  foo -fARG
Options:
  -fARG
# Expected: fromList [(ShortOption 'f',Value "bar")]

$ foo
fromList [(ShortOption 'A',NotPresent),(ShortOption 'G',NotPresent),(ShortOption 'R',NotPresent),(ShortOption 'f',NotPresent)]
# Expected: Usage: ...

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

1 participant