Browse files

Merge pull request #29 from Met48/bugfix

Bugfix for blank pattern among other subcommands
  • Loading branch information...
2 parents f3bc920 + fa484c3 commit 171f23129eb0111612a799605f82f62921699c30 @keleshev keleshev committed Jun 23, 2012
Showing with 3 additions and 2 deletions.
  1. +2 −1 docopt.py
  2. +1 −1 test_docopt.py
View
3 docopt.py
@@ -424,7 +424,8 @@ def printable_usage(doc):
def formal_usage(printable_usage):
pu = printable_usage.split()[1:] # split and drop "usage:"
- return ' '.join('|' if s == pu[0] else s for s in pu[1:])
+
+ return '( ' + ' '.join(') | (' if s == pu[0] else s for s in pu[1:]) + ' )'
def extras(help, version, options, doc):
View
2 test_docopt.py
@@ -87,7 +87,7 @@ def test_printable_and_formal_usage():
prog is a program."""
assert printable_usage(doc) == "Usage: prog [-hv] ARG\n prog N M"
- assert formal_usage(printable_usage(doc)) == "[-hv] ARG | N M"
+ assert formal_usage(printable_usage(doc)) == "( [-hv] ARG ) | ( N M )"
assert printable_usage('uSaGe: prog ARG\n\t \t\n bla') == "uSaGe: prog ARG"

0 comments on commit 171f231

Please sign in to comment.