CLILoader#

class CLILoader(*args, **kwargs)#

Bases: ConfigLoader

Load config from command line.

This uses the standard module argparse. The default action is nargs="*", type=str, and for the destination it replaces dots in the key by a replacement string (_DOT).

Parameters:
add_argument(key, trait)#

Add argument to the parser.

Parameters:
  • key (str)

  • trait (TraitType)

Return type:

None

allow_kebab: bool = True#

If True (default), allows to replace underscore by hyphens in parameters keys.

create_parser(**kwargs)#

Create a parser instance.

Parameters:

kwargs (Any)

Return type:

ArgumentParser

load_config(argv=None)#

Populate the config attribute from CLI.

Use argparser to obtain key/values. Deal with ‘help’ flags.

Parameters:

argv (list[str] | None) – Arguments to parse. If None use the system ones.

Return type:

Iterator[ConfigValue]

prefix: str = 'both'#

How much hyphens to use as prefix, either ‘one’, ‘two’, or ‘both’.