cli Module
Simple CLI builder on top of a defined API
AsDict |
A key/value pair based argparse action |
add basic arguments that should always be available
add_base(parser)
Parameters
Name | Description |
---|---|
parser
|
|
Convert a function signature into argparse parameters
This uses python type annotations to inform how the argparse params are created.
add_func_args(parser, impl)
Parameters
Name | Description |
---|---|
parser
|
|
impl
|
|
Add functions at the implementation layer
add_funcs(inst, subparser)
Parameters
Name | Description |
---|---|
inst
|
|
subparser
|
|
Recurse through objects in a given class instance as argparse subcommands
add_nested(main_parser, parent_parser, inst, api_types, level=0)
Parameters
Name | Description |
---|---|
main_parser
|
|
parent_parser
|
|
inst
|
|
api_types
|
|
level
|
Default value: 0
|
Verify the specified argument is either true or false
arg_bool(arg)
Parameters
Name | Description |
---|---|
arg
|
|
Verify the specified argument is a directory
arg_dir(arg)
Parameters
Name | Description |
---|---|
arg
|
|
Verify the specified argument is a file
arg_file(arg)
Parameters
Name | Description |
---|---|
arg
|
|
Top level argparse creation
build_arg_parser(inst, api_types, version)
Parameters
Name | Description |
---|---|
inst
|
|
api_types
|
|
version
|
|
Get the arguments for the specified function and call it
call_func(func, args)
Parameters
Name | Description |
---|---|
func
|
|
args
|
|
Expose an API via a light-weight CLI
execute_api(api, api_types, version)
Parameters
Name | Description |
---|---|
api
|
|
api_types
|
|
version
|
|
Get function argument names
get_arg_names(func)
Parameters
Name | Description |
---|---|
func
|
|
get the help text based on pydoc strings
get_help_text(impl)
Parameters
Name | Description |
---|---|
impl
|
|
find the appropriate help from subparsers
print_help(parser, args)
Parameters
Name | Description |
---|---|
parser
|
|
args
|
|
Set log verbosity
set_logging(api, verbose)
Parameters
Name | Description |
---|---|
api
|
|
verbose
|
|