Parameters
provide.foundation.cli.click.parameters
¶
Click parameter processing and decorator application.
Handles separation of arguments/options and application of Click decorators based on parameter introspection and type hints.
Classes¶
Functions¶
apply_click_argument
¶
Apply a Click argument decorator to a function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Any
|
Function to decorate |
required |
param
|
ParameterInfo
|
Parameter information |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Decorated function |
Source code in provide/foundation/cli/click/parameters.py
apply_click_option
¶
Apply a Click option decorator to a function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Any
|
Function to decorate |
required |
param
|
ParameterInfo
|
Parameter information |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Decorated function |
Source code in provide/foundation/cli/click/parameters.py
separate_arguments_and_options
¶
separate_arguments_and_options(
params: list[ParameterInfo], force_options: bool = False
) -> tuple[list[ParameterInfo], list[ParameterInfo]]
Separate parameters into arguments and options using Position-Based Hybrid.
Rules: 1. Explicit cli_hint='argument' → argument (even with default) 2. Explicit cli_hint='option' → option (even without default) 3. No hint + no default → argument 4. No hint + has default + bool → option (flag) 5. No hint + has default + non-bool → first becomes optional argument, rest become options (unless force_options=True, then all become options)
Position-Based Hybrid provides natural UX: - First parameter feels like the "main thing" → optional positional argument - Additional parameters → explicit flags - Boolean parameters → always flags
Example
def send(message: str = None, level: str = "INFO", verbose: bool = False): ...
Becomes CLI: send [MESSAGE] --level INFO --verbose
With force_options=True: send --message TEXT --level INFO --verbose
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
list[ParameterInfo]
|
List of ParameterInfo objects |
required |
force_options
|
bool
|
If True, all parameters with defaults become options (disables Position-Based Hybrid for first parameter) |
False
|
Returns:
| Type | Description |
|---|---|
tuple[list[ParameterInfo], list[ParameterInfo]]
|
(arguments, options) tuple of parameter lists |