package main import ( "context" "flag" "fmt" "log" "os" "time" "github.com/fraktal/mev-beta/tools/audit-orchestrator/internal" ) func main() { var ( mode = flag.String("mode", "comprehensive", "Audit mode: quick, standard, comprehensive, continuous, custom") configFile = flag.String("config", "orchestrator-config.yaml", "Configuration file path") outputDir = flag.String("output", "reports/orchestrator", "Output directory") verbose = flag.Bool("verbose", false, "Enable verbose output") dryRun = flag.Bool("dry-run", false, "Perform dry run without executing audits") parallel = flag.Bool("parallel", true, "Run compatible audits in parallel") timeout = flag.Duration("timeout", 60*time.Minute, "Overall timeout for all audits") reportFormat = flag.String("format", "html", "Report format: html, json, pdf, all") dashboardMode = flag.Bool("dashboard", false, "Start interactive dashboard") watchMode = flag.Bool("watch", false, "Continuous monitoring mode") webhookURL = flag.String("webhook", "", "Webhook URL for notifications") schedule = flag.String("schedule", "", "Cron schedule for automatic runs") baselineDir = flag.String("baseline", "", "Baseline reports directory for comparison") thresholds = flag.String("thresholds", "", "Custom quality thresholds file") environment = flag.String("env", "development", "Environment: development, staging, production") integrationMode = flag.Bool("integration", false, "Integration with external systems") metricsExport = flag.Bool("metrics", false, "Export metrics to external systems") ) flag.Parse() // Create output directory if err := os.MkdirAll(*outputDir, 0755); err != nil { log.Fatalf("Failed to create output directory: %v", err) } // Initialize audit orchestrator orchestrator, err := internal.NewAuditOrchestrator(&internal.OrchestratorConfig{ Mode: *mode, ConfigFile: *configFile, OutputDir: *outputDir, Verbose: *verbose, DryRun: *dryRun, Parallel: *parallel, Timeout: *timeout, ReportFormat: *reportFormat, DashboardMode: *dashboardMode, WatchMode: *watchMode, WebhookURL: *webhookURL, Schedule: *schedule, BaselineDir: *baselineDir, Thresholds: *thresholds, Environment: *environment, IntegrationMode: *integrationMode, MetricsExport: *metricsExport, }) if err != nil { log.Fatalf("Failed to initialize audit orchestrator: %v", err) } ctx := context.Background() ctx, cancel := context.WithTimeout(ctx, *timeout) defer cancel() if *dashboardMode { fmt.Println("Starting audit orchestrator dashboard...") if err := orchestrator.StartDashboard(ctx); err != nil { log.Fatalf("Dashboard failed: %v", err) } return } if *watchMode { fmt.Println("Starting continuous monitoring mode...") if err := orchestrator.StartContinuousMonitoring(ctx); err != nil { log.Fatalf("Continuous monitoring failed: %v", err) } return } fmt.Printf("Starting audit orchestration in %s mode...\n", *mode) exitCode, err := orchestrator.RunOrchestration(ctx) if err != nil { log.Fatalf("Audit orchestration failed: %v", err) } fmt.Printf("Audit orchestration complete. Reports saved to: %s\n", *outputDir) fmt.Printf("Exit code: %d\n", exitCode) os.Exit(exitCode) }