Reputation: 10532
Instead of this:
usage: installer.py [-h] [-v] dir
I would like to have this:
usage: installer.py dir [-h] [-v]
Is there a way of specifying the position of positional arguments?
Upvotes: 3
Views: 1738
Reputation: 35
From the argparse Documentation
By default, ArgumentParser calculates the usage message from the arguments it contains:
usage: PROG [-h] [--foo [FOO]] bar [bar ...]
The default message can be overridden with the usage= keyword argument:
>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s [options]')
usage: PROG [options]
Upvotes: 0
Reputation: 5188
If you set a positional argument, this argument can be consumed in either way, so you still can have
installer.py dir [-h] [-v]
And dir would be consumed, this is very similar to the example in the ArgParse documentation: http://docs.python.org/library/argparse.html#example
Upvotes: 2