upsilonconf.config_from_cli

upsilonconf.config_from_cli(args=None, parser=None, config_io=None)

Construct a configuration from a Command Line Interface.

This function adds a configuration group to an argument parser and adds two extra options to the parser: overrides and –config. The –config flag allows to specify a config file to read a basic config from. The overrides option allows to specify one or more key value pairs that will overwrite any config values from the specified config file.

Parameters:
argssequence of str, optional

The list of arguments to parse. If not specified, they are taken from sys.argv.

parserArgumentParser, optional

The CLI parser to use as a base for retrieving configuration options. The parser can not (already) expect a variable number of positional args. Moreover, the parser should not already use the names config or overrides. If not specified, an empty parser will be created.

config_ioConfigIO

The IO to use for reading config files that are passed as argument.

Returns:
configConfigurationBase

The configuration as specified by the command line arguments.

nsNamespace, optional

The namespace with additional arguments from the command line arguments. This is only returned if parser is not None