Coverage for src / ezqt_widgets / cli / main.py: 0.00%
39 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-04 16:14 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-04 16:14 +0000
1# ///////////////////////////////////////////////////////////////
2# CLI_MAIN - CLI Main Entry Point
3# Project: ezqt_widgets
4# ///////////////////////////////////////////////////////////////
6"""
7EzQt Widgets CLI - Main entry point.
9Command-line interface for running examples and utilities.
10"""
12from __future__ import annotations
14# ///////////////////////////////////////////////////////////////
15# IMPORTS
16# ///////////////////////////////////////////////////////////////
17# Third-party imports
18import click
19from rich.panel import Panel
20from rich.text import Text
22# Local imports
23from .._version import __version__
24from ._console import console
25from .commands import demo_group, docs_command, info_command, version_command
27# ///////////////////////////////////////////////////////////////
28# CLI GROUP
29# ///////////////////////////////////////////////////////////////
32@click.group(
33 name="ezqt-widgets",
34 invoke_without_command=True,
35 context_settings={"help_option_names": ["-h", "--help"]},
36)
37@click.version_option(
38 __version__,
39 "-v",
40 "--version",
41 prog_name="EzQt Widgets CLI",
42 message="%(prog)s version %(version)s",
43)
44@click.pass_context
45def cli(ctx: click.Context) -> None:
46 """EzQt Widgets CLI - Launch examples and utilities.
48 A command-line interface for running EzQt Widgets examples
49 and managing the development workflow.
50 """
51 if ctx.invoked_subcommand is None:
52 _display_welcome()
53 click.echo(ctx.get_help())
56def _display_welcome() -> None:
57 """Display a welcome message."""
58 try:
59 welcome_text = Text()
60 welcome_text.append("EzQt Widgets CLI", style="bold bright_blue")
61 welcome_text.append(" - Qt Widgets Toolkit", style="dim white")
63 panel = Panel(
64 welcome_text,
65 title="[bold bright_blue]Welcome[/bold bright_blue]",
66 border_style="bright_blue",
67 padding=(1, 2),
68 )
69 console.print(panel)
70 except (OSError, RuntimeError, ValueError):
71 click.echo("EzQt Widgets CLI - Qt Widgets Toolkit")
74# ///////////////////////////////////////////////////////////////
75# COMMAND GROUPS
76# ///////////////////////////////////////////////////////////////
78# Register commands and groups
79cli.add_command(demo_group)
80cli.add_command(docs_command)
81cli.add_command(info_command)
82cli.add_command(version_command)
85# ///////////////////////////////////////////////////////////////
86# MAIN ENTRY POINT
87# ///////////////////////////////////////////////////////////////
90def main() -> None:
91 """Main entry point for the CLI."""
92 try:
93 cli()
94 except click.ClickException as e:
95 e.show()
96 raise SystemExit(e.exit_code) from e
97 except KeyboardInterrupt as e:
98 console.print("\n[yellow]Interrupted by user[/yellow]")
99 raise SystemExit(1) from e
100 except (OSError, RuntimeError, ValueError) as e:
101 console.print(f"[bold red]Error:[/bold red] {e}")
102 raise SystemExit(1) from e
105if __name__ == "__main__":
106 main()