cliconfig.cli_parser
Parser for CLI commands.
- parse_cli(sys_argv)
Parser for CLI commands.
Return list of config path(s) that are detected with
--config
followed by a space. If multiple paths are provided, they must be separated by a comma and no space around the comma. It also possible to provide a list of paths.Return also a dictionary of parameters from CLI detected with
--<key>=<value>
(with “=” and without spaces around). If no value is provided, it is True by default (like for a flag).- Parameters:
sys_argv (List[str]) – List of arguments from sys.argv.
- Raises:
Value Error – If the
--config
argument (with space) is used more than once.- Return type:
- Returns:
config_paths (List[str]) – List of paths to config files to merge.
cli_params_dict (Dict[str, Any]) – Dictionary of parameters from CLI.
Examples
$ python my_script.py --config config.yaml --foo.bar.param=[1, 2, 3]
Will be parsed as
config_paths=['config.yaml']
andcli_params={'foo.bar.param': [1, 2, 3]}
. It is equivalent to:{'foo': {'bar': {'param': [1, 2, 3]}}
formerge_flat()
andmake_config()
.