Skip to content

Commit

Permalink
Added and adjusted comments
Browse files Browse the repository at this point in the history
Just thought that it could make the code slightly clearer ^^
  • Loading branch information
onzecki committed Sep 30, 2023
1 parent 128fbf9 commit 589f66e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,27 @@ fn matches_requirements(entry: &DirEntry, pattern: &Regex) -> bool {

fn main() {
let args = Args::parse();
// Parse the cli arguments
let re = Regex::new(&args.pattern).unwrap();
// Set "re" as the Regex pattern
for entry_result in WalkDir::new(&args.path)
.into_iter()
.filter_entry(|e| !is_hidden(e) || args.hidden) // Include hidden entries if args.hidden is true
{

let entry = match entry_result{

Ok(entry) => entry,
Err(_) => {
println!("Error reading.");
continue;
// For each file in a directory/directories check whether an entry is valid and unwrap the result
},
}; // Unwrap the Result
};

if matches_requirements(&entry, &re){
println!("{}", entry.path().display());
// Check whether entry matches the Regex
}
}
}

0 comments on commit 589f66e

Please sign in to comment.