Skip to content
Myr

Refactor directory handling

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by David Peter · parent 33eb857 · Browse files · 1 file+11 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−12 removed

  • other:+11 added−12 removed

1 file+11 added−12 removed

modified:src/main.rs+11 added-12 removed
37 unmodified lines
38 let matches = app::build_app().get_matches_from(env::args_os());3940 // Set the current working directory of the process41 if let Some(base_directory) = matches.value_of("base-directory") {42 let basedir = Path::new(base_directory);43 if !filesystem::is_dir(basedir) {42 let base_directory = Path::new(base_directory);43 if !filesystem::is_dir(base_directory) {44 print_error_and_exit!(45 "The '--base-directory' path ('{}') is not a directory.",46 basedir.to_string_lossy()46 base_directory.to_string_lossy()47 );48 }49 if let Err(e) = env::set_current_dir(basedir) {49 if let Err(e) = env::set_current_dir(base_directory) {50 print_error_and_exit!(51 "Could not set '{}' as the current working directory: {}",52 basedir.to_string_lossy(),52 base_directory.to_string_lossy(),53 e54 );55 }56 }5758 // Get the search pattern59 let pattern = matches.value_of("pattern").unwrap_or("");6061 // Get the current working directory62 let current_dir = Path::new(".");63 if !filesystem::is_dir(current_dir) {58 let current_directory = Path::new(".");59 if !filesystem::is_dir(current_directory) {60 print_error_and_exit!("Could not get current directory.");61 }6263 // Get the search pattern64 let pattern = matches.value_of("pattern").unwrap_or("");6566 // Get one or more root directories to search.67 let mut dir_vec: Vec<_> = match matches68 .values_of("path")69 .or_else(|| matches.values_of("search-path"))
9 unmodified lines
79 }80 path_buffer81 })82 .collect::<Vec<_>>(),84 None => vec![current_dir.to_path_buf()],83 None => vec![current_directory.to_path_buf()],84 };8586 if matches.is_present("absolute-path") {87 dir_vec = dir_vec
230 unmodified lines