mirror of
https://github.com/uutils/findutils.git
synced 2026-06-10 15:48:30 -07:00
add --version to the cli
This commit is contained in:
@@ -382,6 +382,10 @@ fn build_matcher_tree(
|
||||
config.help_requested = true;
|
||||
None
|
||||
}
|
||||
"-version" | "--version" => {
|
||||
config.version_requested = true;
|
||||
None
|
||||
}
|
||||
|
||||
_ => return Err(From::from(format!("Unrecognized flag: '{}'", args[i]))),
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ pub struct Config {
|
||||
max_depth: usize,
|
||||
sorted_output: bool,
|
||||
help_requested: bool,
|
||||
version_requested: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -29,6 +30,7 @@ impl Default for Config {
|
||||
max_depth: usize::max_value(),
|
||||
sorted_output: false,
|
||||
help_requested: false,
|
||||
version_requested: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,6 +147,11 @@ fn do_find<'a>(args: &[&str], deps: &'a dyn Dependencies<'a>) -> Result<u64, Box
|
||||
print_help();
|
||||
return Ok(0);
|
||||
}
|
||||
if paths_and_matcher.config.version_requested {
|
||||
print_version();
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
let mut found_count: u64 = 0;
|
||||
for path in paths_and_matcher.paths {
|
||||
found_count += process_dir(
|
||||
@@ -195,6 +202,10 @@ Early alpha implementation. Currently the only expressions supported are
|
||||
);
|
||||
}
|
||||
|
||||
fn print_version() {
|
||||
println!("find (Rust) {}", env!("CARGO_PKG_VERSION"));
|
||||
}
|
||||
|
||||
/// Does all the work for find.
|
||||
///
|
||||
/// All main has to do is pass in the command-line args and exit the process
|
||||
|
||||
Reference in New Issue
Block a user