charmhelpers.cli package¶
charmhelpers.cli.commands module¶
This module loads sub-modules into the python runtime so they can be discovered via the inspect module. In order to prevent flake8 from (rightfully) telling us these are unused modules, throw a ‘ # noqa’ at the end of each import so that the warning is suppressed.
charmhelpers.cli.host module¶
-
charmhelpers.cli.host.mounts()¶ List mounts
-
class
charmhelpers.cli.CommandLine¶ Bases:
object-
argument_parser= None¶
-
exit_code= 0¶
-
formatter= None¶
-
no_output(decorated)¶ Subcommand is not expected to return a value, so don’t print a spurious None.
-
run()¶ Run cli, processing arguments and executing subcommands.
-
subcommand(command_name=None)¶ Decorate a function as a subcommand. Use its arguments as the command-line arguments
-
subcommand_builder(command_name, description=None)¶ Decorate a function that builds a subcommand. Builders should accept a single argument (the subparser instance) and return the function to be run as the command.
-
subparsers= None¶
-
test_command(decorated)¶ Subcommand is a boolean test function, so bool return values should be converted to a 0/1 exit code.
-
-
class
charmhelpers.cli.OutputFormatter(outfile=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)¶ Bases:
object-
add_arguments(argument_parser)¶
-
csv(output)¶ Output data as excel-compatible CSV
-
format_output(output, fmt='raw')¶
-
json(output)¶ Output data in JSON format
-
py(output)¶ Output data as a nicely-formatted python data structure
-
raw(output)¶ Output data as raw string (default)
-
supported_formats¶
-
tab(output)¶ Output data in excel-compatible tab-delimited format
-
yaml(output)¶ Output data in YAML format
-
-
charmhelpers.cli.describe_arguments(func)¶ Analyze a function’s signature and return a data structure suitable for passing in as arguments to an argparse parser’s add_argument() method.