What I mean by multiple level arguments is something like svn help
, after parsing the svn help
part, the following word is considered argument to help
the subcommand.
Is it possible to set this up with optparse
?
According to the python docs, optparse is now considered as deprecated, and won't be developed further; therefore i would strongly suggest you to use the module argparse, whith which you can create "multiple level" arguments.
import argparse
parser = argparse.ArgumentParser()
# Init sub-command
parser_init = subparsers.add_parser('init', help='initialize the things')
parser_init.add_argument(...)
# Help sub-command
parser_help = subparsers.add_parser('help', help='help me!')
parser_help.add_argument(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With