1
0
Fork 0
mirror of https://github.com/archtechx/todo-system.git synced 2025-12-12 00:54:03 +00:00

add todos_path and readme_path to excludes to avoid double counting priority todos

This commit is contained in:
Samuel Štancl 2023-11-23 17:05:51 +01:00
parent b5bbe710ff
commit 887199995a
2 changed files with 27 additions and 18 deletions

View file

@ -39,11 +39,14 @@ struct Args {
fn main() { fn main() {
let args = Args::parse(); let args = Args::parse();
let root_dir: PathBuf = std::env::current_dir().unwrap(); let root_dir: PathBuf = std::env::current_dir().unwrap();
let mut paths: Vec<PathBuf> = vec![]; let mut paths: Vec<PathBuf> = vec![];
let mut excludes: Vec<PathBuf> = vec![]; let mut excludes: Vec<PathBuf> = vec![];
let mut entries: Vec<Entry> = vec![];
let mut stats = Stats::new();
for p in args.paths { for p in args.paths {
let mut path = root_dir.clone(); let mut path = root_dir.clone();
@ -53,7 +56,9 @@ fn main() {
path.push(p); path.push(p);
} }
paths.push(path); if path.exists() {
paths.push(path);
}
} }
for exclude in args.exclude { for exclude in args.exclude {
@ -63,27 +68,28 @@ fn main() {
excludes.push(path); excludes.push(path);
} }
let mut entries: Vec<Entry> = vec![];
let mut stats = Stats::new();
for p in &paths {
scan_dir(p.as_path(), &mut entries, &excludes, &mut stats).unwrap();
}
let mut todos_path = root_dir.clone(); let mut todos_path = root_dir.clone();
todos_path.push(&args.todos); todos_path.push(&args.todos);
if todos_path.exists() {
scan_todo_file(&todos_path, &mut entries).unwrap();
}
let mut readme_path = root_dir.clone(); let mut readme_path = root_dir.clone();
readme_path.push(&args.readme); readme_path.push(&args.readme);
if todos_path.exists() {
excludes.push(todos_path.clone());
scan_todo_file(&todos_path, &mut entries).unwrap();
}
if readme_path.exists() { if readme_path.exists() {
excludes.push(readme_path.clone());
scan_readme_file(&readme_path, &mut entries).unwrap(); scan_readme_file(&readme_path, &mut entries).unwrap();
} }
for p in &paths {
scan_dir(p.as_path(), &mut entries, &excludes, &mut stats).unwrap();
}
render_entries(entries); render_entries(entries);
if args.verbose { if args.verbose {
@ -91,5 +97,7 @@ fn main() {
stats.print(); stats.print();
eprintln!("Paths: {:?}", &paths); eprintln!("Paths: {:?}", &paths);
eprintln!("Excludes: {:?}", &excludes); eprintln!("Excludes: {:?}", &excludes);
eprintln!("todo.md: {:?}", &todos_path);
eprintln!("readme.md: {:?}", &readme_path);
} }
} }

View file

@ -45,6 +45,7 @@ fn clean_line<'a>(line: &'a str, delimiter_word: &str) -> &'a str {
.trim() .trim()
.trim_end_matches("*/") .trim_end_matches("*/")
.trim_end_matches("-->") .trim_end_matches("-->")
.trim_end_matches("--}}")
.trim(); .trim();
} }
@ -128,13 +129,13 @@ pub fn scan_dir(path: &Path, entries: &mut Vec<Entry>, excludes: &Vec<PathBuf>,
continue; continue;
} }
if path.is_dir() { for exclude in excludes {
for exclude in excludes { if path == *exclude {
if path == *exclude { continue 'entry;
continue 'entry;
}
} }
}
if path.is_dir() {
scan_dir(path.as_path(), entries, excludes, stats)? scan_dir(path.as_path(), entries, excludes, stats)?
} else { } else {
stats.visited_files += 1; stats.visited_files += 1;