topmark.cli.cli_types¶
Shared Click parameter types and argument parsing helpers for TopMark.
This module contains reusable Click parameter validators and custom parameter
classes used by TopMark CLI commands. The helpers stay focused on CLI argument
conversion and validation; command-level input planning lives in
topmark.cli.io.
ParamTypeBase ¶
Bases: Protocol
Minimal typed Click parameter base used only during type checking.
Runtime code subclasses click.ParamType directly. This protocol keeps
EnumChoiceParam from inheriting from Any when Click stubs are not
precise enough for strict type checking.
EnumChoiceParam ¶
Bases: ParamTypeBase, Generic[E]
Click parameter type that converts CLI text to an enum member.
The parameter can optionally accept case-insensitive input and present or accept kebab-case spellings for string-valued enum members whose internal values use underscores.
Source code in src/topmark/cli/cli_types.py
convert ¶
Convert CLI text to a member of the configured enum.
Source code in src/topmark/cli/cli_types.py
shell_complete ¶
Tab completion for Click.
Bash: eval "$(_TOPMARK_COMPLETE=bash_source topmark)"
Zsh: eval "$(_TOPMARK_COMPLETE=zsh_source topmark)"
Source code in src/topmark/cli/cli_types.py
FileTypeParam ¶
Validate and convert a CLI argument to an existing file path.
Validates and converts the CLI argument to a Path, raising an error if it does not exist or is not a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Click context. |
required |
param
|
Parameter
|
The Click parameter. |
required |
value
|
object
|
The CLI argument value to validate. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
The validated file path, or None if value is None. |
Raises:
| Type | Description |
|---|---|
BadParameter
|
If the file does not exist or is not a file. |
Source code in src/topmark/cli/cli_types.py
GlobParam ¶
Expand a glob pattern CLI argument to matching file paths.
Expands the given glob pattern string into a list of Path objects matching the
pattern.
- Relative patterns are expanded via
Path.glob(). - Absolute patterns are expanded via
glob.glob(..., recursive=True)becausePath.glob()does not support absolute patterns.
Both approaches support ** for recursive matches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Click context. |
required |
param
|
Parameter
|
The Click parameter. |
required |
value
|
object
|
The glob pattern string. |
required |
Returns:
| Type | Description |
|---|---|
list[Path]
|
Paths matching the glob pattern, or an empty list if |