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

Multiple values in result dict from ellipsis #325

Open
tomschr opened this issue May 25, 2016 · 1 comment
Open

Multiple values in result dict from ellipsis #325

tomschr opened this issue May 25, 2016 · 1 comment

Comments

@tomschr
Copy link

tomschr commented May 25, 2016

Consider the following little program:

"""
usage:
    program -h | --help
    program --version
    program [-v]...
            [-p=<x> | --param=<x>]...
            [--]
            <file>
            [<output>]

Global options:
    --version
        show program version
    -v  raise verbosity

  Input options:
    -p=<x> --param=<x>
        specifies profiling attributes

  Arguments:
    <file>
        input file
    <output>
        optional; save file to output
"""
from docopt import docopt

if __name__ == "__main__":
    cli = docopt(__doc__,
                 help=True,
                 version='doctest version 0.1.0',
                 )
    print(cli)

When I call it with the following options, I'll get:

$ program.py -p 12  foo
{'--': False,
 '--help': False,
 '--param': ['12'],
 '--version': False,
 '-h': False,
 '-v': 0,
 '<file>': 'foo',
 '<output>': None}

However, when I use an additional -p option, I get this:

$ program.py -p 12 -p 42  foo
{'--': False,
 '--help': False,
 '--param': ['12', '42', '42'], # <<< (!)
 '--version': False,
 '-h': False,
 '-v': 0,
 '<file>': 'foo',
 '<output>': None}

This is strange. I would have expected to get a list of ['12', '42'] and not ['12', '42', '42']. I get the same result when I use --param instead of -p.

Maybe I miss something obvious? Any idea? Thanks for reading.

Using docopt 0.6.2 with Python 3.4.1

@mklemm2
Copy link

mklemm2 commented Jun 9, 2016

I've got the same problem with docopt 0.6.2 on python 2.7.11:

Usage:
  winrm-client [options] (--hop=<hostname> (--auth=basic --user=<user> --passwd=<password>|--auth=ntlm --user=<user> --passwd=<password>|--auth=kerberos --realm=<realm> --keytab=<keytab>|--auth=certificates --certificate=<certifcate> --keyfile=<keyfile>) [--nossl])... --interpreter=<interpreter> <scriptfile>
winrm-client.py --hop=jump.example.dev --auth=ntlm --user=user1 --passwd=passwd1 --hop=target.example.dev --auth=basic --user=user2 --passwd=passwd2 --interpreter=powershell script.ps1
{'--auth': ['ntlm', 'basic', 'basic', 'basic', 'basic'],    <<<---- three too many!
 '--certificate': [],
 '--hop': ['jump.example.dev', 'target.example.dev'],
 '--interpreter': 'powershell',
 '--keyfile': [],
 '--keytab': [],
 '--nossl': 0,
 '--passwd': ['passwd1', 'passwd2', 'passwd2'],    <<<---- one too many!
 '--realm': [],
 '--user': ['user1', 'user2', 'user2'],
 '<scriptfile>': 'script.ps1'}

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