Initial upload: Git AI Documentation Generator v0.1.0
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
61
src/cli.py
Normal file
61
src/cli.py
Normal file
@@ -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()
|
||||||
Reference in New Issue
Block a user