cli Module

Simple CLI builder on top of a defined API

Classes

AsDict

A key/value pair based argparse action

Functions

add_base

add basic arguments that should always be available

add_base(parser)

Parameters

Name Description
parser

add_func_args

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_funcs

Add functions at the implementation layer

add_funcs(inst, subparser)

Parameters

Name Description
inst
subparser

add_nested

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

arg_bool

Verify the specified argument is either true or false

arg_bool(arg)

Parameters

Name Description
arg

arg_dir

Verify the specified argument is a directory

arg_dir(arg)

Parameters

Name Description
arg

arg_file

Verify the specified argument is a file

arg_file(arg)

Parameters

Name Description
arg

build_arg_parser

Top level argparse creation

build_arg_parser(inst, api_types, version)

Parameters

Name Description
inst
api_types
version

call_func

Get the arguments for the specified function and call it

call_func(func, args)

Parameters

Name Description
func
args

execute_api

Expose an API via a light-weight CLI

execute_api(api, api_types, version)

Parameters

Name Description
api
api_types
version

get_arg_names

Get function argument names

get_arg_names(func)

Parameters

Name Description
func

get_help_text

get the help text based on pydoc strings

get_help_text(impl)

Parameters

Name Description
impl

print_help

find the appropriate help from subparsers

print_help(parser, args)

Parameters

Name Description
parser
args

set_logging

Set log verbosity

set_logging(api, verbose)

Parameters

Name Description
api
verbose