Expander

Expander

class Expander[source]

Bases: configpile.arg.Arg

Command-line argument that expands into a flag/value pair

Attributes

Note: attributes inherited from parent classes are not shown here, if any

new_flag

Inserted flag in the command line

new_value

Inserted value in the command line

Methods

all_flags

Returns a sequence of all forms of command line flags

argparse_argument_kwargs

Returns the keyword arguments for use with argparse.ArgumentParser.add_argument

inserts

Returns the flag/value pair that is inserted when this command flag is present

make

Constructs an expander that inserts a flag/value pair in the command line

update_dict_

Returns updated values for this argument, used during App construction

update_processor

Updates a config processor with the processing required by this argument

updated

Returns a copy of this argument with some data updated from its declaration context

List of members of Expander

new_flag: str

Inserted flag in the command line

new_value: str

Inserted value in the command line

inserts()[source]

Returns the flag/value pair that is inserted when this command flag is present

Return type

Tuple[str, str]

update_processor(pf)[source]

Updates a config processor with the processing required by this argument

Parameters

pf (ProcessorFactory[TypeVar(_Config, bound= Config)]) – Processor factory

Return type

None

static make(new_flag, new_value, *, help=None, short_flag_name=None, long_flag_name=Derived.KEBAB_CASE)[source]

Constructs an expander that inserts a flag/value pair in the command line

At least one of short_flag_name or long_flag_name must be defined.

Parameters
  • new_flag (str) – Inserted flag, including the hyphen prefix

  • new_value (str) – String value to insert following the flag

Keyword Arguments
  • help – Help description (autodoc/docstring is used otherwise)

  • short_flag_name – Short flag name of this command flag

  • long_flag_name – Long flag name of this command flag

Return type

Expander

argparse_argument_kwargs()[source]

Returns the keyword arguments for use with argparse.ArgumentParser.add_argument

Return type

Mapping[str, Any]

Returns

Keyword arguments mapping

__init__(help, short_flag_name, long_flag_name, new_flag, new_value)
all_flags()

Returns a sequence of all forms of command line flags

Return type

Sequence[str]

update_dict_(name, help, env_prefix)

Returns updated values for this argument, used during App construction

Parameters
  • name (str) – Argument field name

  • help (Optional[str]) – Argument docstring which describes the argument role

  • env_prefix (Optional[str]) – Uppercase prefix for all environment variables

Returns:

Return type

Mapping[str, Any]

updated(name, help, env_prefix)

Returns a copy of this argument with some data updated from its declaration context

Parameters
  • self (TypeVar(_Arg, bound= Arg)) –

  • name (str) – Identifier name

  • help (str) – Help string (derived from autodoc syntax)

  • env_prefix (Optional[str]) – Environment prefix

Return type

TypeVar(_Arg, bound= Arg)

Returns

Updated argument

help: Optional[str]

Help for the argument

short_flag_name: Optional[str]

Short option name, used in command line parsing, prefixed by a single hyphen

long_flag_name: Optional[Union[str, configpile.enums.Derived]]

Long option name used in command line argument parsing

It is in general lowercase, prefixed with -- and words are separated by hyphens.,

If set to