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

The try.docopt.org site does not process repeating positional arguments properly #2

Open
harijay opened this issue Sep 16, 2013 · 5 comments

Comments

@harijay
Copy link

harijay commented Sep 16, 2013

Hi This is an issue in only the browser based trial. For a command like

Usage:
pdb_prepare ... --ref=reference.pdb [--desc]"

If you give the above doc string repeat arguments to test it with for eg.

file1.pdb file2.pdb file4.pdb --ref=test.pdb

The result displayed in the browser has the file positional argument without any spaces.

"": "file1.pdbfile2.pdbfile4.pdb"}

Instead of

'': ['file1.pdb', 'file2.pdb', 'file4.pdb'],

Not an issue with the actual module though.

@keleshev
Copy link
Member

That's true. Thanks for reporting. So far I haven't figured where's the problem.

@keleshev
Copy link
Member

So apparently docopt doesn't work well when argv is a unicode string. I'm pushing a quick fix to this repo, but I need to think more about if it is a problem for docopt itself.

@harijay
Copy link
Author

harijay commented Sep 17, 2013

Awesome ...thanks ..I'll clone the repo afresh.
Was the error only in the webapp?

Hari
On Sep 17, 2013 12:14 PM, "Vladimir Keleshev" [email protected]
wrote:

Check this link out :-)

http://try.docopt.org/?doc=Naval+Fate.%0D%0A%0D%0AUsage%3A%0D%0A++naval_fate.py+ship+new+%3Cname%3E...%0D%0A++naval_fate.py+ship+%3Cname%3E+move+%3Cx%3E+%3Cy%3E+%5B--speed%3D%3Ckn%3E%5D%0D%0A++naval_fate.py+ship+shoot+%3Cx%3E+%3Cy%3E%0D%0A++naval_fate.py+mine+%28set%7Cremove%29+%3Cx%3E+%3Cy%3E+%5B--moored%7C-
-drifting%5D%0D%0A++naval_fate.py+-h+%7C+--help%0D%0A++naval_fate.py+--version%0D%0A%0D%0AOptions%3A%0D%0A++-h+--help+++++Show+this+screen.%0D%0A++--version+++++Show+version.%0D%0A++--speed%3D%3Ckn%3E++Speed+in+knots+%5Bdefault%3A+10%5D.%0D%0A++--moored++++++Moored+%28anchored%29+mine.%0D%0A++--drifting++++Drifting+mine.%0D%0A%0D%0A&argv=ship+new+foo+bar+bazhttp://try.docopt.org/?doc=Naval+Fate.%0D%0A%0D%0AUsage%3A%0D%0A++naval_fate.py+ship+new+%3Cname%3E...%0D%0A++naval_fate.py+ship+%3Cname%3E+move+%3Cx%3E+%3Cy%3E+%5B--speed%3D%3Ckn%3E%5D%0D%0A++naval_fate.py+ship+shoot+%3Cx%3E+%3Cy%3E%0D%0A++naval_fate.py+mine+%28set%7Cremove%29+%3Cx%3E+%3Cy%3E+%5B--moored%7C--drifting%5D%0D%0A++naval_fate.py+-h+%7C+--help%0D%0A++naval_fate.py+--version%0D%0A%0D%0AOptions%3A%0D%0A++-h+--help+++++Show+this+screen.%0D%0A++--version+++++Show+version.%0D%0A++--speed%3D%3Ckn%3E++Speed+in+knots+%5Bdefault%3A+10%5D.%0D%0A++--moored++++++Moored+%28anchored%29+mine.%0D%0A++--drifting++++Drifting+mine.%0D%0A%0D%0A&argv=ship+new+foo+bar+baz


Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-24601124
.

@keleshev
Copy link
Member

Nope, the error is in docopt as well:

Python 2.7.3 (default, Dec 17 2012, 20:20:42) 
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from docopt import docopt
>>> docopt('usage: prog <a>...', 'a b c')
{'<a>': ['a', 'b', 'c']}
>>> docopt('usage: prog <a>...', u'a b c')
{'<a>': u'abc'}
>>> docopt('usage: prog <a>...', ['a', 'b', 'c'])
{'<a>': ['a', 'b', 'c']}
>>> docopt('usage: prog <a>...', [u'a', u'b', u'c'])
{'<a>': u'abc'}

But the error manifests itself only when docopt is passed unicode strings, which does not happen at the command line.

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