Skip to content

Commit 9e4318e

Browse files
author
Nick Spain
authored
Merge pull request #3 from StileEducation/fix-ignore-file-handling
Fix parsing of ignore-file arg and add debug log
2 parents 151c99d + d63538a commit 9e4318e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ OPTIONS:
2626
-h, --help Print this help information.
2727
--dry-run Dry run. Don't output the generated rules files.
2828
--output-file File to write the absent rules to. Defaults to absent.rules.yml in <PATH>.
29-
--ignore-file Path to the file with a list of metrics to ignore.
29+
--ignore-file Path to the file with a list of metrics to ignore. Defaults to ignore_metrics.txt in cargo path.
3030
";
3131

3232
/// A little helper for making [BTreeMap]'s nicer to write. This lets you use
@@ -196,6 +196,7 @@ fn process_rules_dir<P: AsRef<Path>>(
196196
let metrics_to_ignore: Vec<String> = fs::read_to_string(ignore_file)
197197
.map(|contents| contents.lines().map(|l| l.to_string()).collect())
198198
.unwrap_or_default();
199+
log::debug!("Ignoring these metrics {:?}", metrics_to_ignore);
199200

200201
// We only want to write the file out if all is well but it's useful to run
201202
// through the whole thing so we can pick up as many issues as possible in a
@@ -526,14 +527,14 @@ fn parse_options() -> Result<Opts> {
526527
}
527528
let dry_run = args.contains("--dry-run");
528529
let maybe_output_file: Option<PathBuf> = args.opt_value_from_str("--output-file")?;
529-
let rules_dir: PathBuf = args.free_from_str()?;
530530
let ignore_file: PathBuf = args
531531
.opt_value_from_str("--ignore-file")?
532532
.unwrap_or_else(|| {
533533
let mut path = PathBuf::new();
534534
path = path.join(env!("CARGO_MANIFEST_DIR"));
535535
path.join("ignore_metrics.txt")
536536
});
537+
let rules_dir: PathBuf = args.free_from_str()?;
537538
let opts = Opts {
538539
dry_run,
539540
output_file: maybe_output_file.unwrap_or_else(|| rules_dir.join("absent.rules.yml")),

0 commit comments

Comments
 (0)