Skip to content

make date-check more easy to use #1428

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

Merged
merged 2 commits into from
Aug 26, 2022
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
12 changes: 8 additions & 4 deletions ci/date-check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{
convert::TryInto as _,
env, fmt, fs,
path::{Path, PathBuf},
process,
str::FromStr,
};

Expand Down Expand Up @@ -124,9 +125,12 @@ fn filter_dates(
}

fn main() {
let root_dir = env::args()
.nth(1)
.expect("expect root Markdown directory as CLI argument");
let mut args = env::args();
if args.len() == 1 {
eprintln!("error: expected root Markdown directory as CLI argument");
process::exit(1);
}
let root_dir = args.nth(1).unwrap();
let root_dir_path = Path::new(&root_dir);
let glob_pat = format!("{}/**/*.md", root_dir);
let today_chrono = Utc::today();
Expand Down Expand Up @@ -167,7 +171,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);
Expand Down