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.
This commit is contained in:
Tshepang Mbambo 2022-08-14 16:30:07 +02:00 committed by Noah Lev
parent c9a2c851c9
commit 23ae7bb49f
1 changed files with 2 additions and 4 deletions

View File

@ -124,9 +124,7 @@ fn filter_dates(
} }
fn main() { fn main() {
let root_dir = env::args() let root_dir = env::args().nth(1).unwrap_or(".".into());
.nth(1)
.expect("expect root Markdown directory as CLI argument");
let root_dir_path = Path::new(&root_dir); let root_dir_path = Path::new(&root_dir);
let glob_pat = format!("{}/**/*.md", root_dir); let glob_pat = format!("{}/**/*.md", root_dir);
let today_chrono = Utc::today(); let today_chrono = Utc::today();
@ -167,7 +165,7 @@ fn main() {
for (path, dates) in dates_by_file { for (path, dates) in dates_by_file {
println!( println!(
"- [ ] {}", "- [ ] {}",
path.strip_prefix(&root_dir_path).unwrap().display() path.strip_prefix(&root_dir_path).unwrap_or(&path).display(),
); );
for (line, date) in dates { for (line, date) in dates {
println!(" - [ ] line {}: {}", line, date); println!(" - [ ] line {}: {}", line, date);