1====================== 2 Command Line Options 3====================== 4 5Positional Command Line Arguments 6--------------------------------- 7 8Positional command line arguments are supported via a 'positional' Opt 9constructor argument: 10 11.. code-block:: console 12 13 >>> conf = cfg.ConfigOpts() 14 >>> conf.register_cli_opt(cfg.MultiStrOpt('bar', positional=True)) 15 True 16 >>> conf(['a', 'b']) 17 >>> conf.bar 18 ['a', 'b'] 19 20By default, positional arguments are also required. You may opt-out of this 21behavior by setting ``required=False``, to have an optional positional 22argument. 23 24Sub-Parsers 25----------- 26 27It is also possible to use argparse "sub-parsers" to parse additional 28command line arguments using the SubCommandOpt class: 29 30.. code-block:: console 31 32 >>> def add_parsers(subparsers): 33 ... list_action = subparsers.add_parser('list') 34 ... list_action.add_argument('id') 35 ... 36 >>> conf = cfg.ConfigOpts() 37 >>> conf.register_cli_opt(cfg.SubCommandOpt('action', handler=add_parsers)) 38 True 39 >>> conf(args=['list', '10']) 40 >>> conf.action.name, conf.action.id 41 ('list', '10') 42