cli.core package

Submodules

cli.core.app module

class cli.core.app.Flags(sound_enabled: 'bool' = False, no_signal: 'bool' = False, log_enabled: 'bool' = False, git_clean: 'bool' = False, infinite: 'bool' = False, help_all: 'bool' = False, alarm_timeout: 'int' = 60)

Bases: object

alarm_timeout: int = 60
git_clean: bool = False
help_all: bool = False
infinite: bool = False
log_enabled: bool = False
no_signal: bool = False
sound_enabled: bool = False
cli.core.app.main() None
cli.core.app.parse_flags(argv: List[str]) Flags

cli.core.colors module

class cli.core.colors.Fore

Bases: object

BLACK = '\x1b[30m'
BLUE = '\x1b[34m'
CYAN = '\x1b[36m'
GREEN = '\x1b[32m'
MAGENTA = '\x1b[35m'
RED = '\x1b[31m'
WHITE = '\x1b[37m'
YELLOW = '\x1b[33m'
class cli.core.colors.Style

Bases: object

BRIGHT = '\x1b[1m'
DIM = '\x1b[2m'
RESET_ALL = '\x1b[0m'
cli.core.colors.color_text(text: str, color: str) str

cli.core.discovery module

class cli.core.discovery.Command(parts: Tuple[str, ...], module: str, main_path: Path)

Bases: object

A CLI command is a Python package directory under cli/ that contains __main__.py.

Example

cli/build/tree/__main__.py -> parts=(“build”,”tree”), module=”cli.build.tree”

property folder: str | None
main_path: Path
module: str
property name: str
parts: Tuple[str, ...]
property subcommand: str
cli.core.discovery.discover_commands(cli_dir: Path) List[Command]

Recursively find all packages under cli_dir that contain __main__.py.

cli.core.discovery.resolve_command_module(cli_dir: Path, argv_parts: List[str]) tuple[str | None, List[str]]

Resolve the longest argv prefix that matches a discovered command module.

Returns:

(module, remaining_args)

Example

argv_parts=[“deploy”,”container”,”–foo”,”bar”] -> (“cli.deploy.container”, [”–foo”,”bar”])

cli.core.git module

cli.core.git.git_clean_repo() None

cli.core.help module

cli.core.help.extract_description_via_help(module: str) str

Best-effort: run “python -m <module> –help” and extract the first paragraph after usage.

cli.core.help.format_command_help(name: str, description: str, indent: int = 2, col_width: int = 36, width: int = 80) str
cli.core.help.print_global_help(cli_dir: Path) None
cli.core.help.show_full_help_for_all(cli_dir: Path) None
cli.core.help.show_help_for_directory(cli_dir: Path, dir_parts: List[str]) bool

If cli/<dir_parts>/ is a directory, show commands directly below it.

cli.core.run module

class cli.core.run.RunConfig(no_signal: 'bool', sound_enabled: 'bool', alarm_timeout: 'int', log_enabled: 'bool')

Bases: object

alarm_timeout: int
log_enabled: bool
no_signal: bool
sound_enabled: bool
cli.core.run.open_log_file() tuple[TextIO, Path]
cli.core.run.run_command_once(full_cmd: List[str], cfg: RunConfig, log_file: TextIO | None) bool

cli.core.sounds module

cli.core.sounds.failure_with_warning_loop(no_signal: bool, sound_enabled: bool, alarm_timeout: int = 60) None

Plays a warning sound in a loop until timeout; Ctrl+C stops earlier. Sound playback is isolated in a child process to avoid segfaulting the main process.

cli.core.sounds.init_multiprocessing() None
cli.core.sounds.play_sound_in_child(method_name: str) bool
cli.core.sounds.play_start_intro_async() None

Module contents