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

Usage of short options with argument keeps unneeded equal sign #331

Open
kzmkv opened this issue Jun 28, 2016 · 2 comments
Open

Usage of short options with argument keeps unneeded equal sign #331

kzmkv opened this issue Jun 28, 2016 · 2 comments

Comments

@kzmkv
Copy link

kzmkv commented Jun 28, 2016

Small example:

➤  cat example.py
"""Example

Usage:
  example.py [options] <name>...

Options:
  -s=<kn>, --speed=<kn> Speed in km.
"""

from docopt import docopt

args = docopt(__doc__)
print(args)

Using long option:

➤  python3.5 example.py --speed=25 name
{'--speed': '25',
 '<name>': ['name']}

Using short option:

➤  python3.5 example.py -s=25 name
{'--speed': '=25',
 '<name>': ['name']}

Note that --speed value starts from an unneeded equal sign.

@TylerTemp
Copy link

short option can stick value together, but no = needed.

python3.5 example.py -s25 name

equals

python3.5 example.py -s 25 name

equals

python3.5 example.py --speed=25 name

equals

python3.5 example.py --speed 25 name

@bittner
Copy link

bittner commented Nov 21, 2022

But why is specifying -s=<kn> even accepted in the docstring?

Isn't the specification in the docstring invalid, and docopt should tell us?

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

3 participants