cloup._option_groups¶
Implements support to option group.
Classes summary¶
|
|
|
A click.Option with an extra field |
|
Implements support to option groups. |
Functions Summary¶
|
|
|
|
|
|
|
Attaches an option group to the command. This decorator is overloaded with two signatures::. |
Contents¶
-
cloup._option_groups.C¶
-
cloup._option_groups.OptionDecorator¶
-
cloup._option_groups.OptionGroupDecorator¶
-
class
cloup._option_groups.OptionGroup(name: str, help: Optional[str] = None, constraint: Optional[Constraint] = None)[source]¶ - Parameters
name (str) –
help (Optional[str]) –
constraint (Optional[cloup.constraints._core.Constraint]) –
-
get_help_records(self, ctx: click.Context)[source]¶
-
__getitem__(self, i: int) → click.Option[source]¶
-
class
cloup._option_groups.GroupedOption(*args, group: Optional[OptionGroup] = None, **attrs)[source]¶ Bases:
click.OptionA click.Option with an extra field
groupof type OptionGroup- Parameters
group (Optional[cloup._option_groups.OptionGroup]) –
-
class
cloup._option_groups.OptionGroupMixin(*args, align_option_groups: bool = True, **kwargs)[source]¶ Implements support to option groups.
New in version 0.5.0.
Important
In order to check the constraints defined on the option groups, a command must inherits from
cloup.ConstraintMixintoo!- Parameters
align_option_groups (bool) –
-
get_ungrouped_options(self, ctx: click.Context) → Sequence[click.Option][source]¶
-
get_option_group_title(self, ctx: click.Context, opt_group: cloup._option_groups.OptionGroup) → str[source]¶
-
format_option_group(self, ctx: click.Context, formatter: click.HelpFormatter, opt_group: cloup._option_groups.OptionGroup, help_records: Optional[Sequence] = None)[source]¶
-
format_options(self, ctx: click.Context, formatter: click.HelpFormatter, max_option_width: int = 30)[source]¶
-
cloup._option_groups.option(*param_decls, group: Optional[OptionGroup] = None, cls: Type[click.Option] = GroupedOption, **attrs) → OptionDecorator[source]¶ - Parameters
group (Optional[cloup._option_groups.OptionGroup]) –
cls (Type[click.core.Option]) –
- Return type
Callable[[C], C]
-
cloup._option_groups.option_group(name: str, help: str, *options: OptionDecorator, constraint: Optional[Constraint] = None) → OptionGroupDecorator[source]¶ -
cloup._option_groups.option_group(name: str, *options: OptionDecorator, help: Optional[str] = None, constraint: Optional[Constraint] = None) → OptionGroupDecorator Attaches an option group to the command. This decorator is overloaded with two signatures:
@option_group(name: str, *options, help: Optional[str] = None) @option_group(name: str, help: str, *options)
In other words, if the second position argument is a string, it is interpreted as the “help” argument. Otherwise, it is interpreted as the first option; in this case, you can still pass the help as keyword argument.
- Parameters
name (str) – a mandatory name/title for the group
help – an optional help string for the group
options – option decorators like click.option
constraint – a
Constraintto validate on this option group
- Returns
a decorator that attaches the contained options to the decorated function
- Return type
Callable[[C], C]