mirror of
https://github.com/uutils/findutils.git
synced 2026-06-10 15:48:30 -07:00
Run cargo clippy and cargo fmt.
This commit is contained in:
@@ -907,21 +907,21 @@ fn build_matcher_tree(
|
||||
let time = args[i + 1];
|
||||
let newer_time_type = NewerOptionType::from_str(x_option.as_str());
|
||||
// Convert args to unix timestamps. (expressed in numeric types)
|
||||
let comparable_time = match parse_date_str_to_timestamps(time) {
|
||||
Some(timestamp) => timestamp,
|
||||
None => {
|
||||
return Err(From::from(format!(
|
||||
"find: I cannot figure out how to interpret ‘{}’ as a date or time",
|
||||
args[i + 1]
|
||||
)))
|
||||
}
|
||||
let Some(comparable_time) = parse_date_str_to_timestamps(time) else {
|
||||
return Err(From::from(format!(
|
||||
"find: I cannot figure out how to interpret ‘{}’ as a date or time",
|
||||
args[i + 1]
|
||||
)));
|
||||
};
|
||||
i += 1;
|
||||
Some(NewerTimeMatcher::new(newer_time_type, comparable_time).into_box())
|
||||
} else {
|
||||
let file_path = args[i + 1];
|
||||
i += 1;
|
||||
Some(NewerOptionMatcher::new(x_option, y_option, file_path)?.into_box())
|
||||
Some(
|
||||
NewerOptionMatcher::new(&x_option, &y_option, file_path)?
|
||||
.into_box(),
|
||||
)
|
||||
}
|
||||
}
|
||||
None => return Err(From::from(format!("Unrecognized flag: '{}'", args[i]))),
|
||||
|
||||
@@ -124,14 +124,10 @@ pub struct NewerOptionMatcher {
|
||||
}
|
||||
|
||||
impl NewerOptionMatcher {
|
||||
pub fn new(
|
||||
x_option: String,
|
||||
y_option: String,
|
||||
path_to_file: &str,
|
||||
) -> Result<Self, Box<dyn Error>> {
|
||||
pub fn new(x_option: &str, y_option: &str, path_to_file: &str) -> Result<Self, Box<dyn Error>> {
|
||||
let metadata = fs::metadata(path_to_file)?;
|
||||
let x_option = NewerOptionType::from_str(x_option.as_str());
|
||||
let y_option = NewerOptionType::from_str(y_option.as_str());
|
||||
let x_option = NewerOptionType::from_str(x_option);
|
||||
let y_option = NewerOptionType::from_str(y_option);
|
||||
Ok(Self {
|
||||
x_option,
|
||||
y_option,
|
||||
@@ -740,11 +736,8 @@ mod tests {
|
||||
// this file should already exist
|
||||
let old_file = get_dir_entry_for("test_data", "simple");
|
||||
let deps = FakeDependencies::new();
|
||||
let matcher = NewerOptionMatcher::new(
|
||||
x_option.to_string(),
|
||||
y_option.to_string(),
|
||||
&old_file.path().to_string_lossy(),
|
||||
);
|
||||
let matcher =
|
||||
NewerOptionMatcher::new(x_option, y_option, &old_file.path().to_string_lossy());
|
||||
|
||||
assert!(
|
||||
matcher
|
||||
|
||||
+4
-4
@@ -706,11 +706,11 @@ impl InputProcessOptions {
|
||||
}
|
||||
|
||||
fn process_input(
|
||||
builder_options: CommandBuilderOptions,
|
||||
builder_options: &CommandBuilderOptions,
|
||||
mut args: Box<dyn ArgumentReader>,
|
||||
options: &InputProcessOptions,
|
||||
) -> Result<CommandResult, XargsError> {
|
||||
let mut current_builder = CommandBuilder::new(&builder_options);
|
||||
let mut current_builder = CommandBuilder::new(builder_options);
|
||||
let mut have_pending_command = false;
|
||||
let mut result = CommandResult::Success;
|
||||
|
||||
@@ -726,7 +726,7 @@ fn process_input(
|
||||
result.combine(current_builder.execute()?);
|
||||
}
|
||||
|
||||
current_builder = CommandBuilder::new(&builder_options);
|
||||
current_builder = CommandBuilder::new(builder_options);
|
||||
if let Err(ExhaustedCommandSpace { .. }) = current_builder.add_arg(arg) {
|
||||
return Err(XargsError::ArgumentTooLarge);
|
||||
}
|
||||
@@ -1031,7 +1031,7 @@ fn do_xargs(args: &[&str]) -> Result<CommandResult, XargsError> {
|
||||
};
|
||||
|
||||
let result = process_input(
|
||||
builder_options,
|
||||
&builder_options,
|
||||
args,
|
||||
&InputProcessOptions::new(
|
||||
options.exit_if_pass_char_limit,
|
||||
|
||||
Reference in New Issue
Block a user