pynenc.cli.config_cli¶
Module Contents¶
Functions¶
Decorator for caching the output of functions that extract field descriptions. |
|
Extract field descriptions from the docstring of a configuration class. |
|
Add a subparser for the ‘show_config’ command to the main argparse parser. |
|
Execute the ‘show_config’ command for the Pynenc CLI. |
Data¶
API¶
- pynenc.cli.config_cli.T¶
‘TypeVar(…)’
- pynenc.cli.config_cli.config_cls_cache(func: Callable[[Type[pynenc.cli.config_cli.T]], dict[str, str]]) Callable[[Type[pynenc.cli.config_cli.T]], dict[str, str]][source]¶
Decorator for caching the output of functions that extract field descriptions.
This decorator is designed to be applied to functions that process and return descriptions of configuration fields from class docstrings. It caches the results based on the class name to optimize performance by avoiding redundant processing.
param Callable[[Type[T]], dict[str, str]] func: The function to be decorated.
- Returns:
A wrapped function with caching capability.
- pynenc.cli.config_cli.extract_descriptions_from_docstring(config_cls: Type[pynenc.conf.config_base.ConfigPynencBase]) dict[str, str][source]¶
Extract field descriptions from the docstring of a configuration class.
Parses the docstring of the given configuration class (and its parent classes) to extract descriptions for each configuration field. The descriptions are expected to be formatted in a specific way within the docstring.
- Parameters:
config_cls (Type[ConfigPynencBase]) – The configuration class to extract descriptions from.
- Returns:
A dictionary mapping field names to their descriptions.
- pynenc.cli.config_cli.add_config_subparser(subparsers: argparse._SubParsersAction) None[source]¶
Add a subparser for the ‘show_config’ command to the main argparse parser.
This function is responsible for setting up the CLI structure for the ‘show_config’ command, including defining its help message and setting the default function to be executed when this command is selected.
- Parameters:
subparsers (argparse._SubParsersAction) – The subparsers object from the main parser.
- pynenc.cli.config_cli.show_config_command(args: argparse.Namespace) None[source]¶
Execute the ‘show_config’ command for the Pynenc CLI.
This command displays the current configuration of the Pynenc application instance. It uses the configuration class’s docstring to provide detailed information about each configuration field, including its current value and description.
- Parameters:
args (argparse.Namespace) – The parsed CLI arguments, including the Pynenc application instance.