78 lines
1.9 KiB
Python
78 lines
1.9 KiB
Python
"""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()
|