mirror of
https://github.com/sharkdp/fd
synced 2024-09-15 14:10:41 +00:00
cargo fmt
This commit is contained in:
parent
53226f82eb
commit
27caa33729
45
src/app.rs
45
src/app.rs
|
@ -50,22 +50,26 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.short("u")
|
.short("u")
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.hidden(true),
|
.hidden(true),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("case-sensitive")
|
arg("case-sensitive")
|
||||||
.long("case-sensitive")
|
.long("case-sensitive")
|
||||||
.short("s")
|
.short("s")
|
||||||
.overrides_with("ignore-case"),
|
.overrides_with("ignore-case"),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("ignore-case")
|
arg("ignore-case")
|
||||||
.long("ignore-case")
|
.long("ignore-case")
|
||||||
.short("i")
|
.short("i")
|
||||||
.overrides_with("case-sensitive"),
|
.overrides_with("case-sensitive"),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("fixed-strings")
|
arg("fixed-strings")
|
||||||
.long("fixed-strings")
|
.long("fixed-strings")
|
||||||
.short("F")
|
.short("F")
|
||||||
.alias("literal"),
|
.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("follow").long("follow").short("L").alias("dereference"))
|
||||||
.arg(arg("full-path").long("full-path").short("p"))
|
.arg(arg("full-path").long("full-path").short("p"))
|
||||||
.arg(arg("null_separator").long("print0").short("0"))
|
.arg(arg("null_separator").long("print0").short("0"))
|
||||||
|
@ -76,7 +80,8 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.long("maxdepth")
|
.long("maxdepth")
|
||||||
.hidden(true)
|
.hidden(true)
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("file-type")
|
arg("file-type")
|
||||||
.long("type")
|
.long("type")
|
||||||
.short("t")
|
.short("t")
|
||||||
|
@ -95,8 +100,10 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
"executable",
|
"executable",
|
||||||
"e",
|
"e",
|
||||||
"empty",
|
"empty",
|
||||||
]).hide_possible_values(true),
|
])
|
||||||
).arg(
|
.hide_possible_values(true),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
arg("extension")
|
arg("extension")
|
||||||
.long("extension")
|
.long("extension")
|
||||||
.short("e")
|
.short("e")
|
||||||
|
@ -104,7 +111,8 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.number_of_values(1)
|
.number_of_values(1)
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.value_name("ext"),
|
.value_name("ext"),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("exec")
|
arg("exec")
|
||||||
.long("exec")
|
.long("exec")
|
||||||
.short("x")
|
.short("x")
|
||||||
|
@ -112,7 +120,8 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.allow_hyphen_values(true)
|
.allow_hyphen_values(true)
|
||||||
.value_terminator(";")
|
.value_terminator(";")
|
||||||
.value_name("cmd"),
|
.value_name("cmd"),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("exclude")
|
arg("exclude")
|
||||||
.long("exclude")
|
.long("exclude")
|
||||||
.short("E")
|
.short("E")
|
||||||
|
@ -120,14 +129,16 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.value_name("pattern")
|
.value_name("pattern")
|
||||||
.number_of_values(1)
|
.number_of_values(1)
|
||||||
.multiple(true),
|
.multiple(true),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("ignore-file")
|
arg("ignore-file")
|
||||||
.long("ignore-file")
|
.long("ignore-file")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.value_name("path")
|
.value_name("path")
|
||||||
.number_of_values(1)
|
.number_of_values(1)
|
||||||
.multiple(true),
|
.multiple(true),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("color")
|
arg("color")
|
||||||
.long("color")
|
.long("color")
|
||||||
.short("c")
|
.short("c")
|
||||||
|
@ -135,13 +146,15 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.value_name("when")
|
.value_name("when")
|
||||||
.possible_values(&["never", "auto", "always"])
|
.possible_values(&["never", "auto", "always"])
|
||||||
.hide_possible_values(true),
|
.hide_possible_values(true),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("threads")
|
arg("threads")
|
||||||
.long("threads")
|
.long("threads")
|
||||||
.short("j")
|
.short("j")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.value_name("num"),
|
.value_name("num"),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("size")
|
arg("size")
|
||||||
.long("size")
|
.long("size")
|
||||||
.short("S")
|
.short("S")
|
||||||
|
@ -149,12 +162,14 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.number_of_values(1)
|
.number_of_values(1)
|
||||||
.allow_hyphen_values(true)
|
.allow_hyphen_values(true)
|
||||||
.multiple(true),
|
.multiple(true),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
arg("max-buffer-time")
|
arg("max-buffer-time")
|
||||||
.long("max-buffer-time")
|
.long("max-buffer-time")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.hidden(true),
|
.hidden(true),
|
||||||
).arg(arg("pattern"))
|
)
|
||||||
|
.arg(arg("pattern"))
|
||||||
.arg(arg("path").multiple(true))
|
.arg(arg("path").multiple(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ pub fn absolute_path(path: &Path) -> io::Result<PathBuf> {
|
||||||
.as_path()
|
.as_path()
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.trim_left_matches(r"\\?\"),
|
.trim_left_matches(r"\\?\"),
|
||||||
).to_path_buf();
|
)
|
||||||
|
.to_path_buf();
|
||||||
|
|
||||||
Ok(path_buf)
|
Ok(path_buf)
|
||||||
}
|
}
|
||||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -67,7 +67,8 @@ fn main() {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
path_buffer
|
path_buffer
|
||||||
}).collect::<Vec<_>>(),
|
})
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
None => vec![current_dir.to_path_buf()],
|
None => vec![current_dir.to_path_buf()],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,7 +80,8 @@ fn main() {
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
.and_then(|pb| fshelper::absolute_path(pb.as_path()))
|
.and_then(|pb| fshelper::absolute_path(pb.as_path()))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}).collect();
|
})
|
||||||
|
.collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect if the user accidentally supplied a path instead of a search pattern
|
// Detect if the user accidentally supplied a path instead of a search pattern
|
||||||
|
@ -141,8 +143,10 @@ fn main() {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
error(&format!("Error: {} is not a valid size constraint.", sf));
|
error(&format!("Error: {} is not a valid size constraint.", sf));
|
||||||
}).collect()
|
})
|
||||||
}).unwrap_or_else(|| vec![]);
|
.collect()
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| vec![]);
|
||||||
|
|
||||||
let config = FdOptions {
|
let config = FdOptions {
|
||||||
case_sensitive,
|
case_sensitive,
|
||||||
|
@ -233,7 +237,8 @@ fn main() {
|
||||||
"{}\nHint: You can use the '--fixed-strings' option to search for a \
|
"{}\nHint: You can use the '--fixed-strings' option to search for a \
|
||||||
literal string instead of a regular expression",
|
literal string instead of a regular expression",
|
||||||
err.description()
|
err.description()
|
||||||
).as_str(),
|
)
|
||||||
|
.as_str(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,8 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
||||||
let wq = Arc::clone(&receiver_wtq);
|
let wq = Arc::clone(&receiver_wtq);
|
||||||
ctrlc::set_handler(move || {
|
ctrlc::set_handler(move || {
|
||||||
wq.store(true, Ordering::Relaxed);
|
wq.store(true, Ordering::Relaxed);
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn the thread that receives all results through the channel.
|
// Spawn the thread that receives all results through the channel.
|
||||||
|
|
|
@ -106,7 +106,8 @@ fn format_output_error(args: &[&str], expected: &str, actual: &str) -> String {
|
||||||
diff::Result::Left(l) => format!("-{}", l),
|
diff::Result::Left(l) => format!("-{}", l),
|
||||||
diff::Result::Both(l, _) => format!(" {}", l),
|
diff::Result::Both(l, _) => format!(" {}", l),
|
||||||
diff::Result::Right(r) => format!("+{}", r),
|
diff::Result::Right(r) => format!("+{}", r),
|
||||||
}).collect::<Vec<_>>()
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
format!(
|
format!(
|
||||||
|
@ -128,7 +129,8 @@ fn normalize_output(s: &str, trim_left: bool) -> String {
|
||||||
.map(|line| {
|
.map(|line| {
|
||||||
let line = if trim_left { line.trim_left() } else { line };
|
let line = if trim_left { line.trim_left() } else { line };
|
||||||
line.replace('/', &std::path::MAIN_SEPARATOR.to_string())
|
line.replace('/', &std::path::MAIN_SEPARATOR.to_string())
|
||||||
}).collect::<Vec<_>>();
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
lines.sort_by_key(|s| s.clone());
|
lines.sort_by_key(|s| s.clone());
|
||||||
|
|
||||||
|
|
|
@ -1028,7 +1028,8 @@ fn test_invalid_utf8() {
|
||||||
fs::File::create(
|
fs::File::create(
|
||||||
te.test_root()
|
te.test_root()
|
||||||
.join(OsStr::from_bytes(b"test1/test_\xFEinvalid.txt")),
|
.join(OsStr::from_bytes(b"test1/test_\xFEinvalid.txt")),
|
||||||
).unwrap();
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
te.assert_output(&["", "test1/"], "test1/test_<74>invalid.txt");
|
te.assert_output(&["", "test1/"], "test1/test_<74>invalid.txt");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue