Add CLI module files
This commit is contained in:
63
vibeguard/cli/main.py
Normal file
63
vibeguard/cli/main.py
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
"""VibeGuard CLI main entry point."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import click
|
||||||
|
from rich.console import Console
|
||||||
|
|
||||||
|
from vibeguard.cli.theme import VibeGuardTheme
|
||||||
|
from vibeguard.utils.config import Config, load_config
|
||||||
|
|
||||||
|
from vibeguard.cli.commands.analyze import analyze
|
||||||
|
from vibeguard.cli.commands.init import init
|
||||||
|
from vibeguard.cli.commands.report import report
|
||||||
|
|
||||||
|
|
||||||
|
console = Console(theme=VibeGuardTheme.get_theme())
|
||||||
|
|
||||||
|
|
||||||
|
@click.group()
|
||||||
|
@click.option("--verbose", "-v", is_flag=True, help="Enable verbose output")
|
||||||
|
@click.option("--config", "-c", type=click.Path(exists=True), help="Path to config file")
|
||||||
|
@click.option(
|
||||||
|
"--output",
|
||||||
|
"-o",
|
||||||
|
type=click.Choice(["console", "json", "html", "sarif"]),
|
||||||
|
default="console",
|
||||||
|
help="Output format",
|
||||||
|
)
|
||||||
|
@click.pass_context
|
||||||
|
def main(ctx: click.Context, verbose: bool, config: str | None, output: str) -> None:
|
||||||
|
"""VibeGuard - AI Code Anti-Pattern Detector.
|
||||||
|
|
||||||
|
Scans code repositories for patterns commonly introduced by AI coding assistants.
|
||||||
|
"""
|
||||||
|
ctx.ensure_object(dict)
|
||||||
|
|
||||||
|
cfg = load_config(config) if config else Config()
|
||||||
|
cfg.verbose = verbose
|
||||||
|
cfg.output_format = output
|
||||||
|
|
||||||
|
ctx.obj["config"] = cfg
|
||||||
|
ctx.obj["console"] = console
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
console.print("[bold]VibeGuard[/bold] - AI Code Anti-Pattern Detector")
|
||||||
|
console.print(f"Version: 0.1.0")
|
||||||
|
console.print(f"Output format: {output}")
|
||||||
|
console.print()
|
||||||
|
|
||||||
|
|
||||||
|
main.add_command(analyze, "analyze")
|
||||||
|
main.add_command(init, "init")
|
||||||
|
main.add_command(report, "report")
|
||||||
|
|
||||||
|
|
||||||
|
def cli() -> None:
|
||||||
|
"""Entry point for the CLI."""
|
||||||
|
main(prog_name="vibeguard")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
cli()
|
||||||
Reference in New Issue
Block a user