try.docopt.org
try.docopt.org copied to clipboard
The try.docopt.org site does not process repeating positional arguments properly
Hi This is an issue in only the browser based trial. For a command like
Usage:
pdb_prepare
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.
"
Instead of
'
Not an issue with the actual module though.
That's true. Thanks for reporting. So far I haven't figured where's the problem.
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.
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+baz
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/docopt/try.docopt.org/issues/2#issuecomment-24601124 .
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.