cargo fmt

This commit is contained in:
sharkdp 2018-09-27 23:01:38 +02:00
parent 53226f82eb
commit 27caa33729
6 changed files with 50 additions and 25 deletions

View File

@ -50,22 +50,26 @@ pub fn build_app() -> App<'static, 'static> {
.short("u")
.multiple(true)
.hidden(true),
).arg(
)
.arg(
arg("case-sensitive")
.long("case-sensitive")
.short("s")
.overrides_with("ignore-case"),
).arg(
)
.arg(
arg("ignore-case")
.long("ignore-case")
.short("i")
.overrides_with("case-sensitive"),
).arg(
)
.arg(
arg("fixed-strings")
.long("fixed-strings")
.short("F")
.alias("literal"),
).arg(arg("absolute-path").long("absolute-path").short("a"))
)
.arg(arg("absolute-path").long("absolute-path").short("a"))
.arg(arg("follow").long("follow").short("L").alias("dereference"))
.arg(arg("full-path").long("full-path").short("p"))
.arg(arg("null_separator").long("print0").short("0"))
@ -76,7 +80,8 @@ pub fn build_app() -> App<'static, 'static> {
.long("maxdepth")
.hidden(true)
.takes_value(true),
).arg(
)
.arg(
arg("file-type")
.long("type")
.short("t")
@ -95,8 +100,10 @@ pub fn build_app() -> App<'static, 'static> {
"executable",
"e",
"empty",
]).hide_possible_values(true),
).arg(
])
.hide_possible_values(true),
)
.arg(
arg("extension")
.long("extension")
.short("e")
@ -104,7 +111,8 @@ pub fn build_app() -> App<'static, 'static> {
.number_of_values(1)
.takes_value(true)
.value_name("ext"),
).arg(
)
.arg(
arg("exec")
.long("exec")
.short("x")
@ -112,7 +120,8 @@ pub fn build_app() -> App<'static, 'static> {
.allow_hyphen_values(true)
.value_terminator(";")
.value_name("cmd"),
).arg(
)
.arg(
arg("exclude")
.long("exclude")
.short("E")
@ -120,14 +129,16 @@ pub fn build_app() -> App<'static, 'static> {
.value_name("pattern")
.number_of_values(1)
.multiple(true),
).arg(
)
.arg(
arg("ignore-file")
.long("ignore-file")
.takes_value(true)
.value_name("path")
.number_of_values(1)
.multiple(true),
).arg(
)
.arg(
arg("color")
.long("color")
.short("c")
@ -135,13 +146,15 @@ pub fn build_app() -> App<'static, 'static> {
.value_name("when")
.possible_values(&["never", "auto", "always"])
.hide_possible_values(true),
).arg(
)
.arg(
arg("threads")
.long("threads")
.short("j")
.takes_value(true)
.value_name("num"),
).arg(
)
.arg(
arg("size")
.long("size")
.short("S")
@ -149,12 +162,14 @@ pub fn build_app() -> App<'static, 'static> {
.number_of_values(1)
.allow_hyphen_values(true)
.multiple(true),
).arg(
)
.arg(
arg("max-buffer-time")
.long("max-buffer-time")
.takes_value(true)
.hidden(true),
).arg(arg("pattern"))
)
.arg(arg("pattern"))
.arg(arg("path").multiple(true))
}

View File

@ -33,7 +33,8 @@ pub fn absolute_path(path: &Path) -> io::Result<PathBuf> {
.as_path()
.to_string_lossy()
.trim_left_matches(r"\\?\"),
).to_path_buf();
)
.to_path_buf();
Ok(path_buf)
}

View File

@ -67,7 +67,8 @@ fn main() {
));
}
path_buffer
}).collect::<Vec<_>>(),
})
.collect::<Vec<_>>(),
None => vec![current_dir.to_path_buf()],
};
@ -79,7 +80,8 @@ fn main() {
.canonicalize()
.and_then(|pb| fshelper::absolute_path(pb.as_path()))
.unwrap()
}).collect();
})
.collect();
}
// Detect if the user accidentally supplied a path instead of a search pattern
@ -141,8 +143,10 @@ fn main() {
return f;
}
error(&format!("Error: {} is not a valid size constraint.", sf));
}).collect()
}).unwrap_or_else(|| vec![]);
})
.collect()
})
.unwrap_or_else(|| vec![]);
let config = FdOptions {
case_sensitive,
@ -233,7 +237,8 @@ fn main() {
"{}\nHint: You can use the '--fixed-strings' option to search for a \
literal string instead of a regular expression",
err.description()
).as_str(),
)
.as_str(),
),
}
}

View File

@ -106,7 +106,8 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
let wq = Arc::clone(&receiver_wtq);
ctrlc::set_handler(move || {
wq.store(true, Ordering::Relaxed);
}).unwrap();
})
.unwrap();
}
// Spawn the thread that receives all results through the channel.

View File

@ -106,7 +106,8 @@ fn format_output_error(args: &[&str], expected: &str, actual: &str) -> String {
diff::Result::Left(l) => format!("-{}", l),
diff::Result::Both(l, _) => format!(" {}", l),
diff::Result::Right(r) => format!("+{}", r),
}).collect::<Vec<_>>()
})
.collect::<Vec<_>>()
.join("\n");
format!(
@ -128,7 +129,8 @@ fn normalize_output(s: &str, trim_left: bool) -> String {
.map(|line| {
let line = if trim_left { line.trim_left() } else { line };
line.replace('/', &std::path::MAIN_SEPARATOR.to_string())
}).collect::<Vec<_>>();
})
.collect::<Vec<_>>();
lines.sort_by_key(|s| s.clone());

View File

@ -1028,7 +1028,8 @@ fn test_invalid_utf8() {
fs::File::create(
te.test_root()
.join(OsStr::from_bytes(b"test1/test_\xFEinvalid.txt")),
).unwrap();
)
.unwrap();
te.assert_output(&["", "test1/"], "test1/test_<74>invalid.txt");