From 1ab452d77694556aca9cd22e53dfcdb110bd8e48 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 1 Feb 2026 21:45:43 +0000 Subject: [PATCH] Initial upload: Devtoolbelt v1.0.0 - unified CLI toolkit for developers --- devtoolbelt/cli.py | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 devtoolbelt/cli.py diff --git a/devtoolbelt/cli.py b/devtoolbelt/cli.py new file mode 100644 index 0000000..583a545 --- /dev/null +++ b/devtoolbelt/cli.py @@ -0,0 +1,77 @@ +"""Main CLI entry point for Devtoolbelt.""" + +import sys +from typing import Optional + +import click +from rich import print as rprint +from rich.panel import Panel + +from .commands.database import database +from .commands.api import api +from .commands.utils import utils +from .interactive import start_interactive + + +@click.group() +@click.option( + "--config", "-c", + type=click.Path(exists=True), + help="Path to configuration file." +) +@click.pass_context +def main(ctx: click.Context, config: Optional[str]): + """Devtoolbelt - A unified CLI toolkit for developers.""" + ctx.ensure_object(dict) + ctx.obj["config"] = config + + +@main.command("version", short_help="Show version information") +def version(): + """Show version information.""" + rprint(Panel( + "[bold green]Devtoolbelt[/bold green] v1.0.0\n" + "A unified CLI toolkit for developers", + title="Devtoolbelt", + subtitle="https://7000pct.gitea.bloupla.net/7000pctAUTO/devtoolbelt" + )) + + +@main.command("interactive", short_help="Start interactive mode") +@click.option( + "--config", "-c", + type=click.Path(exists=True), + help="Path to configuration file." +) +def interactive(config: Optional[str]): + """Start interactive shell mode.""" + start_interactive(config) + + +@main.command("shell", short_help="Start interactive mode (alias for interactive)") +@click.pass_context +def shell(ctx: click.Context): + """Start interactive shell mode (alias for interactive).""" + config = ctx.obj.get("config") + start_interactive(config) + + +main.add_command(database) +main.add_command(api) +main.add_command(utils) + + +def cli(): + """Entry point for the CLI.""" + try: + main() + except click.ClickException as e: + rprint(f"[red]Error: {e.message}[/red]") + sys.exit(1) + except Exception as e: + rprint(f"[red]Unexpected error: {e}[/red]") + sys.exit(1) + + +if __name__ == "__main__": + cli()