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

Short options in docopt not returning correct values #504

Open
khoopes opened this issue Oct 25, 2022 · 1 comment
Open

Short options in docopt not returning correct values #504

khoopes opened this issue Oct 25, 2022 · 1 comment

Comments

@khoopes
Copy link

khoopes commented Oct 25, 2022

I am trying to use short options in docopt like this:

Usage:
    someCMD [-a] [-b] [-c <cVar>] [-d <dVar>] 

Options:
    -h, --help  Show this screen
    -a      Show a stuff
    -b      Show b stuff
    -c <cVar>   c stuff with var [default: thing1]
    -d <dVar>   d stuff with var [default: thing2]

But that is not giving the anticipated result. For example someCMD -c anything puts the value under the dVar key in the resulting json. someCMD -c anything -d anythingelse doesnt work at all. someCMD -d anythingelse does put the value under dVar but cVar is set to someCMD instead of its default value.

Here is a link to try it yourself using the docopt online tool.

What am I missing?

@bittner
Copy link

bittner commented Nov 21, 2022

Looks like docopt evaluates the <cVar> as a positional argument when no -c is around. That feels like a bug.

Shouldn't also -c -d populate cVar and dVar with the specified default values? Instead they're set to null.

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

2 participants