Skip to content

Commit 2cc4d9e

Browse files
authored
Merge pull request #6 from script3r/cursor/optimize-slow-directory-scanning-and-add-progress-613b
Optimize slow directory scanning and add progress
2 parents 57f98f1 + c9de25a commit 2cc4d9e

File tree

2 files changed

+165
-112
lines changed

2 files changed

+165
-112
lines changed

crates/cli/src/main.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,25 @@ fn main() -> Result<()> {
157157
.unwrap()
158158
.progress_chars("#>-")
159159
);
160-
pb.set_message("Scanning files...");
160+
pb.set_message("Starting scan...");
161+
162+
// Show immediate feedback
163+
pb.println("🔍 Initializing scanner and discovering files...");
161164

162165
cfg.progress_callback = Some(Arc::new(move |processed, total, findings| {
163-
pb.set_length(total as u64);
164-
pb.set_position(processed as u64);
165-
pb.set_message(format!("Found {} findings", findings));
166+
if total > 0 {
167+
pb.set_length(total as u64);
168+
pb.set_position(processed as u64);
169+
if processed == 0 {
170+
pb.set_message(format!("Found {} files to scan", total));
171+
} else if processed < total {
172+
pb.set_message(format!("Processing files... {} findings so far", findings));
173+
} else {
174+
pb.set_message(format!("Completed! Found {} findings", findings));
175+
}
176+
} else {
177+
pb.set_message("Discovering files...");
178+
}
166179
}));
167180
}
168181

@@ -177,13 +190,21 @@ fn main() -> Result<()> {
177190

178191
let scanner = Scanner::new(&reg, dets, cfg);
179192
if args.dry_run {
193+
if !args.progress {
194+
eprintln!("🔍 Discovering files...");
195+
}
180196
let files = scanner.discover_files(&args.paths);
181197
for p in files {
182198
println!("{}", p.display());
183199
}
184200
return Ok(());
185201
}
186202

203+
// Show startup message if not using progress bar
204+
if !args.progress && !args.json {
205+
eprintln!("🔍 Starting scan of {} path(s)...", args.paths.len());
206+
}
207+
187208
let findings = scanner.run(&args.paths)?;
188209

189210
// Clear progress bar if it was shown

0 commit comments

Comments
 (0)