Skip to content

_cli

_cli

CLI entry point for terok-dbus — desktop notification tools.

Builds the argument parser from the :data:COMMANDS registry so the standalone CLI and the terok integration layer share a single source of truth for subcommand definitions.

main()

Entry point for terok-dbus.

Source code in src/terok_dbus/_cli.py
def main() -> None:
    """Entry point for ``terok-dbus``."""
    parser = _build_parser()
    args = parser.parse_args()

    cmd_lookup = {cmd.name: cmd for cmd in COMMANDS}
    cmd_def = cmd_lookup.get(args.command)

    if cmd_def is None or cmd_def.handler is None:
        parser.print_help()
        sys.exit(2)

    # Build kwargs from parsed args, excluding the 'command' key
    kwargs = {k: v for k, v in vars(args).items() if k != "command"}

    try:
        asyncio.run(cmd_def.handler(**kwargs))
    except KeyboardInterrupt:
        sys.exit(130)