Configuration#
Commands are defined by command()
,
which accepts various Feud configuration key-word arguments such as
negate_flags
or show_help_defaults
directly.
Similarly, Groups can be directly configured with Feud
configuration key-word arguments provided when subclassing Group
.
However, in some cases it may be useful to have a reusable configuration
object that can be provided to other commands or groups. This functionality is
implemented by config()
, which creates a configuration which can be
provided to command()
or Group
.
API reference#
- feud.config.config(*, negate_flags=None, show_help_defaults=None, show_help_datetime_formats=None, show_help_envvars=None, pydantic_kwargs=None, rich_click_kwargs=None)#
Create a reusable configuration for
command()
orGroup
objects.See
Config
for the underlying configuration class.- Parameters:
negate_flags (bool | None) – Whether to automatically add a negated variant for boolean flags.
show_help_defaults (bool | None) – Whether to display default parameter values in command help.
show_help_datetime_formats (bool | None) – Whether to display datetime parameter formats in command help.
show_help_envvars (bool | None) – Whether to display environment variable names in command help.
pydantic_kwargs (dict[str, Any] | None) – Validation settings for
pydantic.validate_call_decorator.validate_call()
.rich_click_kwargs (dict[str, Any] | None) –
Styling settings for
rich-click
.See all available options here (as of
rich-click
v1.7.2).
- Returns:
The reusable configuration.
- Return type:
Examples
Providing a configuration to
command()
.>>> import feud >>> config = feud.config(show_help_defaults=False) >>> @feud.command(config=config) ... def func(*, opt1: int, opt2: bool = True): ... pass >>> all(not param.show_default for param in func.params) True
Providing a configuration to
Group
.Note that the configuration is internally forwarded to the commands defined within the group.
>>> import feud >>> config = feud.config(show_help_defaults=False) >>> class CLI(feud.Group, config=config): ... def func(*, opt1: int, opt2: bool = True): ... pass >>> all(not param.show_default for param in CLI.func.params) True
- pydantic model feud.config.Config#
Class representing a reusable configuration for
command()
andGroup
objects.Warning
This class should NOT be instantiated directly —
config()
should be used to create aConfig
instead.- Fields:
- field pydantic_kwargs: dict[str, Any] = {}#
Validation settings for
pydantic.validate_call_decorator.validate_call()
.
- field rich_click_kwargs: dict[str, Any] = {'show_arguments': True}#
Styling settings for
rich-click
.See all available options here (as of
rich-click
v1.7.2).