diff --git a/src/main.rs b/src/main.rs index cf01ee876169e8bea31ca5506b252d7c00f9f302..8c4761acd1a0283a8eda870b229de55ad88908bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,10 +42,14 @@ struct Exa { } impl Exa { - fn run(&mut self, args_file_names: &[String]) { + fn run(&mut self, mut args_file_names: Vec) { let mut files = Vec::new(); let mut dirs = Vec::new(); + if args_file_names.is_empty() { + args_file_names.push(".".to_owned()); + } + for file_name in args_file_names.iter() { match File::from_path(Path::new(&file_name), None) { Err(e) => { @@ -145,7 +149,7 @@ fn main() { match Options::getopts(&args) { Ok((options, paths)) => { let mut exa = Exa { options: options }; - exa.run(&paths); + exa.run(paths); }, Err(e) => { println!("{}", e); diff --git a/src/options.rs b/src/options.rs index 7563485359bd6f2f1553d8531032e47ab2804088..3551a892db22e264e9a358a115dac1b85fc2eba0 100644 --- a/src/options.rs +++ b/src/options.rs @@ -83,15 +83,8 @@ impl Options { return Err(Misfire::Version); } - let path_strs = if matches.free.is_empty() { - vec![ ".".to_string() ] - } - else { - matches.free.clone() - }; - let options = try!(Options::deduce(&matches)); - Ok((options, path_strs)) + Ok((options, matches.free)) } /// Whether the View specified in this set of options includes a Git @@ -611,7 +604,7 @@ mod test { #[test] fn no_args() { let args = Options::getopts(&[]).unwrap().1; - assert_eq!(args, vec![ ".".to_string() ]) + assert!(args.is_empty()); // Listing the `.` directory is done in main.rs } #[test]