cloup._option_groups
¶
Implements support to option group.
Classes¶
|
Contains the information of an option group and identifies it. |
|
A click.Option with an extra field |
|
Implements support to option groups. |
Functions¶
|
|
|
|
|
|
|
Returns a decorator that annotates a function with an option group. |
Attributes¶
A decorator that registers an option to the wrapped function. |
|
A decorator that registers an option group to the wrapped function. |
Contents¶
-
cloup._option_groups.
C
¶
-
cloup._option_groups.
OptionAdder
¶ A decorator that registers an option to the wrapped function.
-
cloup._option_groups.
OptionGroupAdder
¶ A decorator that registers an option group to the wrapped function.
-
class
cloup._option_groups.
OptionGroup
(name, help=None, constraint=None, hidden=False)[source]¶ - Parameters
name (str) –
help (Optional[str]) –
constraint (Optional[cloup.constraints._core.Constraint]) –
hidden (bool) –
-
property
options
(self)¶ - Return type
Sequence[click.Option]
-
get_help_records
(self, ctx)[source]¶ - Parameters
ctx (click.Context) –
- Return type
-
class
cloup._option_groups.
GroupedOption
(*args, group=None, **attrs)[source]¶ Bases:
click.Option
A click.Option with an extra field
group
of type OptionGroup- Parameters
group (Optional[cloup._option_groups.OptionGroup]) –
-
class
cloup._option_groups.
OptionGroupMixin
(*args, align_option_groups=None, **kwargs)[source]¶ Implements support to option groups.
Changed in version 0.8.0: This mixin now relies on
cloup.HelpFormatter
to align help sections. If aclick.HelpFormatter
is used with aTypeError
is raised.Changed in version 0.8.0: Removed
format_option_group
. Addedget_default_option_group
andmake_option_group_help_section
.New in version 0.5.0.
Important
In order to check the constraints defined on the option groups, a command must inherits from
cloup.ConstraintMixin
too!- Parameters
align_option_groups (Optional[bool]) –
-
get_ungrouped_options
(self, ctx)[source]¶ - Parameters
ctx (click.Context) –
- Return type
Sequence[click.Option]
-
make_option_group_help_section
(self, group, ctx)[source]¶ Returns a HelpSection for an OptionGroup, i.e. an object containing the title, the optional description and the options’ definitions for this option group.
New in version 0.8.0.
- Parameters
group (OptionGroup) –
ctx (click.Context) –
- Return type
-
must_align_option_groups
(self, ctx, default=True)[source]¶ New in version 0.8.0.
- Parameters
ctx (Optional[click.Context]) –
- Return type
-
get_default_option_group
(self, ctx)[source]¶ New in version 0.8.0.
- Parameters
ctx (click.Context) –
- Return type
-
format_options
(self, ctx, formatter)[source]¶ - Parameters
ctx (click.Context) –
formatter (click.HelpFormatter) –
- Return type
-
cloup._option_groups.
option
(*param_decls, group=None, cls=GroupedOption, **attrs)[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: OptionAdder, constraint: Optional[cloup.constraints.Constraint] = None, hidden: bool = False) → OptionGroupAdder[source]¶ -
cloup._option_groups.
option_group
(name: str, *options: OptionAdder, help: Optional[str] = None, constraint: Optional[cloup.constraints.Constraint] = None, hidden: bool = False) → OptionGroupAdder Returns a decorator that annotates a function with an option group.
The
help
is an optional description and can be provided either as keyword argument or as 2nd positional argument after thename
of the group:# help as keyword argument @option_group(name, *options, help=None, ...) # help as 2nd positional argument @option_group(name, help, *options, ...)
- Parameters
name – this is shown as heading of the help section describing the option group.
help – an optional description shown below the name; can be provided as keyword argument or 2nd positional argument.
options – an arbitrary number of decorators like click.option, which annotate the input function with one
Option
.constraint – an optional instance of
Constraint
(see constraints for more info); a description of the constraint will be shown between squared brackets aside the option group title (or below it if too long).hidden – if
True
, the option group and all its options are hidden from the help page (all contained options will have theirhidden
attribute set toTrue
).