Add CLI commands and output renderer
This commit is contained in:
44
vibeguard/cli/commands/report.py
Normal file
44
vibeguard/cli/commands/report.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""Report command for VibeGuard CLI."""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import click
|
||||
|
||||
from vibeguard.reports.generator import ReportGenerator
|
||||
|
||||
|
||||
@click.command(name="report")
|
||||
@click.argument("input_file", type=click.Path(exists=True))
|
||||
@click.option("--json", "output_json", is_flag=True, help="Convert to JSON")
|
||||
@click.option("--html", "output_html", type=click.Path(), help="Output HTML report to file")
|
||||
@click.option("--sarif", "output_sarif", type=click.Path(), help="Output SARIF report to file")
|
||||
@click.pass_obj
|
||||
def report(
|
||||
ctx: dict[str, Any],
|
||||
input_file: str,
|
||||
output_json: bool,
|
||||
output_html: str | None,
|
||||
output_sarif: str | None,
|
||||
) -> None:
|
||||
"""Generate reports from VibeGuard analysis results."""
|
||||
config = ctx["config"]
|
||||
console = ctx["console"]
|
||||
|
||||
generator = ReportGenerator()
|
||||
issues = generator.load_json(input_file)
|
||||
|
||||
if not issues:
|
||||
console.print("[warning]No issues found in input file[/warning]")
|
||||
return
|
||||
|
||||
if output_json:
|
||||
import json
|
||||
|
||||
console.print_json(data=issues)
|
||||
elif output_html:
|
||||
generator.generate_html(issues, output_html)
|
||||
console.print(f"[success]HTML report saved to: {output_html}[/success]")
|
||||
elif output_sarif:
|
||||
generator.generate_sarif(issues, output_sarif)
|
||||
console.print(f"[success]SARIF report saved to: {output_sarif}[/success]")
|
||||
Reference in New Issue
Block a user