From 038aa0c897e6a072ed0949448180c10b2c57ff48 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 1 Feb 2026 19:31:01 +0000 Subject: [PATCH] Initial upload: Git AI Documentation Generator v0.1.0 --- src/cli.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/cli.py diff --git a/src/cli.py b/src/cli.py new file mode 100644 index 0000000..2f513b5 --- /dev/null +++ b/src/cli.py @@ -0,0 +1,61 @@ +"""Main CLI entry point for git-ai-doc-generator.""" + +import sys + +import click + +from src.commands.api_docs import api_docs +from src.commands.changelog import changelog +from src.commands.commit import commit +from src.config import load_config +from src.output import console, error_console + + +@click.group() +@click.option("--config", "-c", type=click.Path(exists=True), help="Path to config file") +@click.option("--model", "-m", help="Ollama model to use") +@click.option("--ollama-host", help="Ollama server URL") +@click.pass_context +def main( + ctx: click.Context, + config: str | None, + model: str | None, + ollama_host: str | None, +) -> None: + """Generate commit messages, changelogs, and API docs with local AI.""" + cfg = load_config(config) + if model: + cfg.model = model + if ollama_host: + cfg.ollama_host = ollama_host + ctx.ensure_object(dict) + ctx.obj["config"] = cfg + + +main.add_command(commit, "commit") +main.add_command(changelog, "changelog") +main.add_command(api_docs, "api-docs") + + +@main.command() +def version() -> None: + """Show version information.""" + from src import __version__ + + console.print(f"[bold]Git AI Documentation Generator[/bold] v{__version__}") + console.print("A privacy-focused CLI tool using local AI models via Ollama.") + + +def cli() -> None: + """Entry point for the CLI.""" + try: + main(standalone_mode=False) + except click.exceptions.Exit as e: + sys.exit(e.exit_code) + except Exception as e: + error_console.print(f"[red]Error:[/red] {e}") + sys.exit(1) + + +if __name__ == "__main__": + cli()