Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ignore-dirs cli arg #90

Merged
merged 1 commit into from
Jul 5, 2023
Merged
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
17 changes: 15 additions & 2 deletions kondo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ struct Opt {
#[arg(name = "DIRS")]
dirs: Vec<PathBuf>,

/// Directories to ignore. Will also prevent recursive traversal within.
#[arg(short = 'I', long)]
ignored_dirs: Vec<PathBuf>,

/// Quiet mode. Won't output to the terminal. -qq prevents all output.
#[arg(short, long, action = clap::ArgAction::Count, value_parser = clap::value_parser!(u8).range(0..3))]
quiet: u8,
Expand Down Expand Up @@ -143,11 +147,13 @@ fn discover(
scan_options: &ScanOptions,
project_min_age: u64,
result_sender: SyncSender<DiscoverData>,
ignored_dirs: &[PathBuf],
) {
for project in dirs
.iter()
.flat_map(|dir| scan(dir, scan_options))
.filter_map(|p| p.ok())
.filter(|p| ignored_dirs.iter().all(|i| !p.path.starts_with(i)))
{
let artifact_dir_sizes: Vec<_> = project
.artifact_dirs()
Expand Down Expand Up @@ -280,7 +286,7 @@ fn interactive_prompt(
}

fn main() -> Result<(), Box<dyn Error>> {
let opt = Opt::parse();
let mut opt = Opt::parse();

if opt.quiet > 0 && !opt.all {
eprintln!("Quiet mode can only be used with --all.");
Expand All @@ -298,8 +304,15 @@ fn main() -> Result<(), Box<dyn Error>> {
let (proj_delete_send, proj_delete_recv) = std::sync::mpsc::channel::<(Project, u64)>();

let project_min_age = opt.older;
let ignored_dirs = prepare_directories(std::mem::take(&mut opt.ignored_dirs))?;
std::thread::spawn(move || {
discover(dirs, &scan_options, project_min_age, proj_discover_send);
discover(
dirs,
&scan_options,
project_min_age,
proj_discover_send,
&ignored_dirs,
);
});

let delete_handle = std::thread::spawn(move || process_deletes(proj_delete_recv));
Expand Down