cloup.constraints.common
¶
Useful functions used for implementing constraints and predicates.
Functions Summary¶
|
Defines what it means for a parameter of a specific kind to be “set”. |
|
Filters |
|
|
|
|
|
|
|
|
|
|
|
|
|
Contents¶
-
cloup.constraints.common.
param_value_is_set
(param: click.Parameter, value: Any) → bool[source]¶ Defines what it means for a parameter of a specific kind to be “set”.
All cases are obvious besides that of boolean options: - (common rule) if the value is
None
, the parameter is unset; - a parameter that takes multiple values is set if at least one argument is provided; - a boolean flag is set only if True; - a boolean option is set if not None, even if it’s False.- Parameters
param (click.core.Parameter) –
value (Any) –
- Return type
-
cloup.constraints.common.
get_params_whose_value_is_set
(params: Iterable[Parameter], values: Dict[str, Any]) → List[Parameter][source]¶ Filters
params
returning only the parameters that have a value. Boolean flags are considered “set” if their value isTrue
.- Parameters
params (Iterable[click.core.Parameter]) –
values (Dict[str, Any]) –
- Return type
List[click.core.Parameter]
-
cloup.constraints.common.
get_required_params
(params: Iterable[Parameter]) → List[Parameter][source]¶ - Parameters
params (Iterable[click.core.Parameter]) –
- Return type
List[click.core.Parameter]
-
cloup.constraints.common.
get_param_label
(param: click.Parameter) → str[source]¶ - Parameters
param (click.core.Parameter) –
- Return type
-
cloup.constraints.common.
join_param_labels
(params: Iterable[Parameter], sep: str = ', ') → str[source]¶
-
cloup.constraints.common.
format_param
(param: click.Parameter) → str[source]¶ - Parameters
param (click.core.Parameter) –
- Return type
-
cloup.constraints.common.
format_param_list
(param_list: Iterable[Parameter], indent=2) → str[source]¶ - Parameters
param_list (Iterable[click.core.Parameter]) –
- Return type
-
cloup.constraints.common.
param_value_by_name
(ctx: click.Context, name: str) → Any[source]¶ - Parameters
ctx (click.core.Context) –
name (str) –
- Return type
Any