cli_types
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| ClickCommandLike toprompt.cli_types Protocol for Click-like command objects. |
||
| TyperCommandLike toprompt.cli_types Protocol for Typer-like command objects. |
🛈 DocStrings¶
ClickCommandLike
¶
Bases: Protocol
Protocol for Click-like command objects.
Source code in src/toprompt/cli_types.py
TyperCommandLike
¶
Bases: Protocol
Protocol for Typer-like command objects.
Source code in src/toprompt/cli_types.py
format_cli_command
¶
Format a CommandInfo object into a prompt-friendly string recursively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
CommandInfo
|
The CommandInfo object to format |
required |
indent_level
|
int
|
Current indentation level for nested commands |
0
|
Source code in src/toprompt/cli_types.py
is_cli_object
¶
Check if object is a supported CLI framework object.
Safely checks for installed CLI frameworks before doing type checks. Prevents import errors if a framework is not installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
Object to check |
required |
Source code in src/toprompt/cli_types.py
is_click_command
¶
Check if object looks like a Click command/group.
Tries to detect Click commands by their distinctive attributes, without requiring Click to be installed.
Source code in src/toprompt/cli_types.py
is_typer_command
¶
Check if object looks like a Typer app.
Tries to detect Typer apps by their distinctive attributes, without requiring Typer to be installed.