httk.core.register.cli

Command-line registry and command metadata.

Attributes

Classes

CLICommand

Store registration metadata for one top-level httk command.

Functions

register_cli_command(name, handler, summary)

Register a lazy top-level httk command.

known_cli_commands()

Return registered top-level command names without resolving handlers.

cli_command(name)

Return command metadata without importing its implementation.

Module Contents

httk.core.register.cli.CLIHandler[source]
class httk.core.register.cli.CLICommand[source]

Store registration metadata for one top-level httk command.

Parameters:
  • name – The lowercase hyphen-separated command name.

  • handler – The command callable or lazy reference.

  • summary – The one-line command summary.

name: str[source]
handler: str | collections.abc.Callable[Ellipsis, Any][source]
summary: str[source]
resolve()[source]

Import and return the registered command implementation.

Returns:

The resolved command handler.

Return type:

CLIHandler

httk.core.register.cli.register_cli_command(name, handler, summary)[source]

Register a lazy top-level httk command.

A handler is either a callable or a lazy "module:callable" reference with the contract (argv: Sequence[str], context: CLIContext) -> int. Names use lowercase, hyphen-separated command syntax. Registration is intentionally strict: reserved names and duplicate registrations are errors rather than order-dependent overrides.

Parameters:
  • name (str) – The lowercase hyphen-separated command name.

  • handler (str | collections.abc.Callable[Ellipsis, Any]) – The command callable or lazy "module:callable" reference.

  • summary (str) – The nonempty one-line command summary.

Raises:
  • TypeError – If handler is neither callable nor a lazy reference.

  • ValueError – If the name, handler reference, summary, or registration is invalid.

httk.core.register.cli.known_cli_commands()[source]

Return registered top-level command names without resolving handlers.

Returns:

Registered command names in sorted order.

Return type:

list[str]

httk.core.register.cli.cli_command(name)[source]

Return command metadata without importing its implementation.

Parameters:

name (str) – The command name to look up.

Returns:

Command metadata, or None if it is not registered.

Return type:

CLICommand | None