python cmd2多参数解析器

python cmd2多参数解析器,python,python-3.x,command-line-arguments,subparsers,cmd2,Python,Python 3.x,Command Line Arguments,Subparsers,Cmd2,我有4个论点,例如:a,b,c,d。用户可以选择输入a或b或c或d,否则a或c,否则仅输入“a”或“d”,就像这样,遵循所有概率。为此,我们将介绍如何编写参数解析器 subscription_parser = argparse.ArgumentParser() subscribe_parent = argparse.ArgumentParser(add_help=False) stream_parsers = subscription_parser.add_subparsers(title='

我有4个论点,例如:a,b,c,d。用户可以选择输入a或b或c或d,否则a或c,否则仅输入“a”或“d”,就像这样,遵循所有概率。为此,我们将介绍如何编写参数解析器

subscription_parser = argparse.ArgumentParser()
subscribe_parent =  argparse.ArgumentParser(add_help=False)
stream_parsers = subscription_parser.add_subparsers(title='subcommands', help='subcommand help')
stream_parser_sub = stream_parsers.add_parser('stream', parents=[subscribe_parent], help='callhome_port help')
stream_parser_sub.add_argument('stream', type=str, help='stream name')
# create_parser_filter = argparse.ArgumentParser()
filter_parser = stream_parser_sub.add_subparsers(title='subcommands', help='subcommand help')
filter_sub_parser = filter_parser.add_parser('filter',parents=[subscribe_parent], help='callhome_port help')
filter_sub_parser.add_argument('filter', type=str, help='filter value')
# create_parser_start = argparse.ArgumentParser()
start_parser = filter_sub_parser.add_subparsers(title='subcommands', help='subcommand help')
start_sub_parser = start_parser.add_parser('starttime', parents=[subscribe_parent], help='callhome_port help')
start_sub_parser.add_argument('start', type=str, help='starttime')
# create_parser_stop = argparse.ArgumentParser()
stop_parser = start_sub_parser.add_subparsers(title='subcommands', help='subcommand help')
stop_sub_parser = stop_parser.add_parser('stoptime', parents=[subscribe_parent], help='callhome_port help')
stop_sub_parser.add_argument('stop', type=str, help='stoptime')

感谢您提前

抽出时间保护您自己,并使用
docopt
@Alex谢谢,我从cmd2获得的大多数案例。所以,如果我要改变这个包,对我来说会很复杂。在cmd2中是否有实现的可能性?