Skip to content
Myr

Minor refactoring

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 da9af8c · Browse files · 1 file+12 added−13 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+12 added−13 removed

  • other:+12 added−13 removed

1 file+12 added−13 removed

modified:src/main.rs+12 added-13 removed
77 unmodified lines
78 let passed_arguments = matches79 .values_of_os("path")80 .or_else(|| matches.values_of_os("search-path"));8182 // Assign current directory to search vector.83 let mut dir_vec: Vec<_> = vec![current_directory.to_path_buf()];8485 // Assign any valid arguments to search vector.86 if let Some(paths) = passed_arguments {87 dir_vec = vec![];82 let mut search_paths = if let Some(paths) = passed_arguments {83 let mut directories = vec![];84 for path in paths {85 let path_buffer = PathBuf::from(path);86 if filesystem::is_dir(&path_buffer) {91 dir_vec.push(path_buffer);92 }93 else {87 directories.push(path_buffer);88 } else {89 print_error(format!(90 "Search path '{}' is not a directory.",91 path_buffer.to_string_lossy()92 ));93 }94 }100 }9596 directories97 } else {98 vec![current_directory.to_path_buf()]99 };100101 // Check if we have no valid search paths.103 if dir_vec.is_empty() {102 if search_paths.is_empty() {103 return Err(anyhow!("No valid search paths given."));104 }105106 if matches.is_present("absolute-path") {108 dir_vec = dir_vec107 search_paths = search_paths108 .iter()109 .map(|path_buffer| {110 path_buffer111 .canonicalize()
296 unmodified lines
408 e.to_string()409 )410 })?;411413 walk::scan(&dir_vec, Arc::new(re), Arc::new(config))412 walk::scan(&search_paths, Arc::new(re), Arc::new(config))413}414415fn main() {416 let result = run();
10 unmodified lines