Subcommands¶
Subcommands module.
Submodule for handling arguments to subcommands.
- codestream.cli.subcommands.argument(*name_or_flags, **kwargs)¶
Argument is a convenience function.
Used to properly format arguments to pass to the subcommand decorator.
- codestream.cli.subcommands.parse_extra(parser, namespace)¶
Parse extra.
Take the ‘extra’ attribute from the global namespace and re-parse it to create separate namespaces for all other subcommands.
- codestream.cli.subcommands.subcommand(args=None, parent=_SubParsersAction(option_strings=[], dest='subcommand', nargs='A...', const=None, default=None, type=None, choices={'docs': ArgumentParser(prog='codestream-cli docs', usage=None, description='\n Docs.\n\n Subcommand to serve the sphinx documentation on localhost.\n ', formatter_class=<class 'argparse.RawTextHelpFormatter'>, conflict_handler='error', add_help=True), 'pipelines': ArgumentParser(prog='codestream-cli pipelines', usage=None, description='\n Code Stream pipelines.\n\n Subcommand for working with vRA Code Stream pipelines.\n\n Only one subcommand will be processed per execution.\n ', formatter_class=<class 'argparse.RawTextHelpFormatter'>, conflict_handler='error', add_help=True), 'token': ArgumentParser(prog='codestream-cli token', usage=None, description='\n Token.\n\n Subcommand for obtaining a vRA token by providing a username and password.\n ', formatter_class=<class 'argparse.RawTextHelpFormatter'>, conflict_handler='error', add_help=True), 'variables': ArgumentParser(prog='codestream-cli variables', usage=None, description='\n Variable.\n\n Subcommand for working with vRA variables.\n ', formatter_class=<class 'argparse.RawTextHelpFormatter'>, conflict_handler='error', add_help=True)}, required=False, help='subcommand help', metavar=None))¶
Define a new subcommand.
A decorator to define a new subcommand in a sanity-preserving way.
The function will be stored in the
funcvariable when the parser parses arguments so that it can be called directly like this example.Usage example:
args = parser.parse_args() args.func(args)
Usage example:
@subcommand( [ argument( "-d", "--debug", help="Enable debug mode", action="store_true" ) ] ) def subcommand(args): print(args)
Then on the command line:
$ python cli.py subcommand -d