Skip to content

Commit 87cece7

Browse files
committed
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.
1 parent d3daa1f commit 87cece7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

ci/date-check/src/main.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ fn filter_dates(
124124
}
125125

126126
fn main() {
127-
let root_dir = env::args()
128-
.nth(1)
129-
.expect("expect root Markdown directory as CLI argument");
127+
let root_dir = env::args().nth(1).unwrap_or(".".into());
130128
let root_dir_path = Path::new(&root_dir);
131129
let glob_pat = format!("{}/**/*.md", root_dir);
132130
let today_chrono = Utc::today();
@@ -167,7 +165,7 @@ fn main() {
167165
for (path, dates) in dates_by_file {
168166
println!(
169167
"- [ ] {}",
170-
path.strip_prefix(&root_dir_path).unwrap().display()
168+
path.strip_prefix(&root_dir_path).unwrap_or(&path).display(),
171169
);
172170
for (line, date) in dates {
173171
println!(" - [ ] line {}: {}", line, date);

0 commit comments

Comments
 (0)