import click
import json
from civicshield_core.analyzer.engine import run_scan
from civicshield_core.analyzer.phishing_detector import PhishingDetector

@click.group()
def cli():
    """CivicShield Engine CLI"""
    pass

@click.command()
@click.option("--url", required=True, help="Target URL to scan")
def scan(url):
    click.echo(f"Starting full scan on {url}...")
    report = run_scan(url)
    click.echo(f"\nScan complete. Found {len(report['findings'])} findings.")
    summary = report.get('summary', {})
    click.echo(f"Risk Severity Counts: {json.dumps(summary.get('severity_counts', {}))}")

@click.command()
@click.option("--url", required=True, help="Target URL to check for phishing")
def phish(url):
    click.echo(f"Checking {url} for phishing indicators...")
    detector = PhishingDetector()
    result = detector.analyze(url)
    click.echo(f"Result: {json.dumps(result, indent=2)}")

cli.add_command(scan)
cli.add_command(phish)

if __name__ == "__main__":
    cli()
