feat: start mailbox evidence scanner
This commit is contained in:
parent
8292ffe41d
commit
8532583182
26 changed files with 1733 additions and 18 deletions
55
src/email_connect/cli.py
Normal file
55
src/email_connect/cli.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from .adapter_contract import adapter_descriptor
|
||||
from .config import load_config
|
||||
from .scanner import scan_mailbox
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser(prog="email-connect")
|
||||
sub = parser.add_subparsers(dest="command", required=True)
|
||||
|
||||
scan = sub.add_parser("scan-mailbox", help="Scan a return mailbox or fixture directory.")
|
||||
scan.add_argument("--config", required=True)
|
||||
scan.add_argument("--out", default=None)
|
||||
scan.add_argument("--full-rescan", action="store_true")
|
||||
scan.add_argument("--since", default=None)
|
||||
scan.add_argument("--report-only-new", action="store_true")
|
||||
scan.add_argument("--dry-run", action="store_true")
|
||||
scan.add_argument("--fixture-dir", default=None)
|
||||
|
||||
sub.add_parser("adapter-descriptor", help="Print the initial coordination-engine adapter descriptor.")
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
if args.command == "adapter-descriptor":
|
||||
print(json.dumps(adapter_descriptor(), indent=2, sort_keys=True))
|
||||
return 0
|
||||
|
||||
if args.command == "scan-mailbox":
|
||||
config = load_config(args.config)
|
||||
result = scan_mailbox(
|
||||
config,
|
||||
output_dir=args.out,
|
||||
full_rescan=args.full_rescan,
|
||||
report_only_new=args.report_only_new,
|
||||
dry_run=args.dry_run,
|
||||
fixture_dir=args.fixture_dir,
|
||||
)
|
||||
print(f"scan_id={result.scan.scan_id}")
|
||||
print(f"messages_seen={result.scan.messages_seen}")
|
||||
print(f"messages_new={result.scan.messages_new}")
|
||||
print(f"messages_parsed={result.scan.messages_parsed}")
|
||||
print(f"evidence_events_created={result.scan.evidence_events_created}")
|
||||
if result.report_path:
|
||||
print(f"report_path={Path(result.report_path)}")
|
||||
return 0
|
||||
|
||||
return 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue