gufo.thor.cli.base¶
CLI entrypoint and shared Click context.
CLIDispatcher
¶
Bases: Group
Click command group that dynamically discovers CLI entrypoints.
get_command(ctx, name)
¶
Get a CLI command by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Current CLI context. |
required |
name
|
str
|
Command name. |
required |
Returns:
| Type | Description |
|---|---|
Command | None
|
The command, or |
invoke(ctx)
¶
Run the selected command and convert Thor cancellation to exit 1.
list_commands(ctx)
¶
List available CLI commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Current CLI context. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Sorted list of available command names. |
Context
¶
CLI execution context.
config
cached
property
¶
target
cached
property
¶
Load the configured target, creating a default config if needed.
Returns:
| Type | Description |
|---|---|
BaseTarget
|
Configured target instance. |
verbose
property
writable
¶
Whether verbose output is enabled.
debug(msg)
¶
Print a debug message to standard output if verbose mode is enabled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
Message to print. |
required |
die(msg=None)
¶
Print an error message and terminate the process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str | None
|
Optional error message to print. |
None
|
get_ui_url()
¶
Build the NOC UI URL from the current configuration.
Returns:
| Type | Description |
|---|---|
str
|
HTTPS URL for the configured NOC web interface. |
prepare()
¶
Prepare services configuration.
print(msg)
¶
Print a message to standard output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
str
|
Message to print. |
required |
Entrypoint
¶
CLI entrypoint registered with the Gufo Loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Command
|
Click command associated with the entrypoint. |
required |
entrypoint(fn)
¶
Register a Click command as a Gufo Thor CLI entrypoint.
The decorator must be applied to a command created by
click.command.
Example::
@entrypoint
@click.command("version", short_help="Show Gufo Thor version")
def version() -> None:
...
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Command
|
Click command to register. |
required |
Returns:
| Type | Description |
|---|---|
Entrypoint
|
Entrypoint wrapping the Click command. |