Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```sh
- $ cat hoge.py
- from docopt import docopt
- __doc__ = """Can docopt allow the sme name argument differ single/multiple between subcommands?
- Usage:
- hoge.py a <arg>
- hoge.py b <arg>...
- """
- args = docopt(__doc__)
- print('subcommand: %s' % ('a' if args['a'] else 'b' if args['b'] else None))
- print('<arg> = %s' % repr(args['<arg>']))
- ```
- ```sh
- $ python3 hoge.py a
- Usage:
- hoge.py a <arg>
- hoge.py b <arg>...
- $ python3 hoge.py a 1
- subcommand: a
- <arg> = ['1']
- $ python3 hoge.py a 1 2
- Usage:
- hoge.py a <arg>
- hoge.py b <arg>...
- $ python3 hoge.py b
- Usage:
- hoge.py a <arg>
- hoge.py b <arg>...
- $ python3 hoge.py b 1
- subcommand: b
- <arg> = ['1']
- $ python3 hoge.py b 1 2
- subcommand: b
- <arg> = ['1', '2']
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement