From 23ae7bb49f2fdcd3e1bb16ae290423100052811e Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Sun, 14 Aug 2022 16:30:07 +0200 Subject: [PATCH] make date-check more easy to use One could not run it like the following, for the would be a panic: cargo run --manifest-path ci/date-check/Cargo.toml . Also, remove the need to specify argument, in which case, current_dir is assumed. --- ci/date-check/src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/date-check/src/main.rs b/ci/date-check/src/main.rs index bb3542f2..ea8b2431 100644 --- a/ci/date-check/src/main.rs +++ b/ci/date-check/src/main.rs @@ -124,9 +124,7 @@ fn filter_dates( } fn main() { - let root_dir = env::args() - .nth(1) - .expect("expect root Markdown directory as CLI argument"); + let root_dir = env::args().nth(1).unwrap_or(".".into()); let root_dir_path = Path::new(&root_dir); let glob_pat = format!("{}/**/*.md", root_dir); let today_chrono = Utc::today(); @@ -167,7 +165,7 @@ fn main() { for (path, dates) in dates_by_file { println!( "- [ ] {}", - path.strip_prefix(&root_dir_path).unwrap().display() + path.strip_prefix(&root_dir_path).unwrap_or(&path).display(), ); for (line, date) in dates { println!(" - [ ] line {}: {}", line, date);