From 5137ac0640a07555731d6ef2631faacfbe6c64c9 Mon Sep 17 00:00:00 2001 From: Olivier Date: Fri, 11 Aug 2023 20:31:08 +0100 Subject: [PATCH] Fix ignore rules --- yama/src/bin/yamascan.rs | 10 +++++++--- yama/src/scan.rs | 11 ++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/yama/src/bin/yamascan.rs b/yama/src/bin/yamascan.rs index bf58473..dfea42b 100644 --- a/yama/src/bin/yamascan.rs +++ b/yama/src/bin/yamascan.rs @@ -52,7 +52,11 @@ pub enum YamaScanCommand { /// Show dust-style usage graph of the current directory, excluding excluded files. #[command(alias = "du")] - Usage {}, + Usage { + /// Specify an ignore rule. Can use multiple times. + #[arg(short = 'I', long = "ignore")] + ignore: Vec, + }, } #[tokio::main] @@ -66,7 +70,7 @@ async fn main() -> eyre::Result<()> { .init(); match YamaScanCommand::parse() { - YamaScanCommand::Usage {} => { + YamaScanCommand::Usage { ignore } => { let idd = InitialDisplayData { short_paths: true, is_reversed: false, @@ -76,7 +80,7 @@ async fn main() -> eyre::Result<()> { iso: false, }; - let scan = scan::scan(Path::new("."), &Vec::new()).context("Couldn't scan")?; + let scan = scan::scan(Path::new("."), &ignore).context("Couldn't scan")?; let top_nodes = assemble_display_tree_from_scan_entries(scan)?.children; let root_display_node = dust_style_filetree_display::filter::get_biggest( diff --git a/yama/src/scan.rs b/yama/src/scan.rs index 370bfbb..526989a 100644 --- a/yama/src/scan.rs +++ b/yama/src/scan.rs @@ -1,4 +1,5 @@ use eyre::{bail, eyre, Context, ContextCompat}; +use ignore::overrides::OverrideBuilder; use ignore::WalkBuilder; use patricia_tree::PatriciaMap; use std::cmp::max; @@ -117,9 +118,17 @@ pub fn scan(root: &Path, ignores: &Vec) -> eyre::Result