Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,56 @@ fn main() -> Result<()> {
ProgressStyle::default_bar()
.template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {pos}/{len} files ({percent}%) | {msg}")
.unwrap()
.progress_chars("#>-"),
.progress_chars("#>-")
);
pb.set_message("Scanning files...");
pb.set_message("Starting scan...");

// Show immediate feedback
pb.println("🔍 Initializing scanner and discovering files...");

cfg.progress_callback = Some(Arc::new(move |processed, total, findings| {
pb.set_length(total as u64);
pb.set_position(processed as u64);
pb.set_message(format!("Found {} findings", findings));
if total > 0 {
pb.set_length(total as u64);
pb.set_position(processed as u64);
if processed == 0 {
pb.set_message(format!("Found {} files to scan", total));
} else if processed < total {
pb.set_message(format!("Processing files... {} findings so far", findings));
} else {
pb.set_message(format!("Completed! Found {} findings", findings));
}
} else {
pb.set_message("Discovering files...");
}
}));
}

// Stream JSONL findings as they arrive
if args.json {
cfg.result_callback = Some(Arc::new(move |f: &Finding| {
if let Ok(s) = serde_json::to_string(f) {
println!("{}", s);
}
}));
}

let scanner = Scanner::new(&reg, dets, cfg);
if args.dry_run {
if !args.progress {
eprintln!("🔍 Discovering files...");
}
let files = scanner.discover_files(&args.paths);
for p in files {
println!("{}", p.display());
}
return Ok(());
}

// Show startup message if not using progress bar
if !args.progress && !args.json {
eprintln!("🔍 Starting scan of {} path(s)...", args.paths.len());
}

let findings = scanner.run(&args.paths)?;

// Clear progress bar if it was shown
Expand All @@ -183,9 +213,7 @@ fn main() -> Result<()> {
}

if args.json {
for f in &findings {
println!("{}", serde_json::to_string(f)?);
}
// Already streamed above
} else {
print_table(&findings);
}
Expand Down
Loading
Loading