mirror of
https://github.com/sharkdp/fd
synced 2024-10-06 07:49:18 +00:00
Update for new rustfmt
This commit is contained in:
parent
9628d7fdcb
commit
c1ef68662c
|
@ -80,7 +80,7 @@ matrix:
|
|||
# skip the global install step
|
||||
install:
|
||||
- cargo install --debug --force rustfmt-nightly
|
||||
script: cargo fmt -- --write-mode=diff
|
||||
script: cargo fmt -- --check
|
||||
|
||||
addons:
|
||||
apt:
|
||||
|
|
|
@ -15,10 +15,10 @@ struct Help {
|
|||
}
|
||||
|
||||
macro_rules! doc {
|
||||
($map: expr, $name: expr, $short: expr) => {
|
||||
($map:expr, $name:expr, $short:expr) => {
|
||||
doc!($map, $name, $short, $short)
|
||||
};
|
||||
($map: expr, $name: expr, $short: expr, $long: expr) => {
|
||||
($map:expr, $name:expr, $short:expr, $long:expr) => {
|
||||
$map.insert(
|
||||
$name,
|
||||
Help {
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -37,8 +37,9 @@ use atty::Stream;
|
|||
use regex::{RegexBuilder, RegexSetBuilder};
|
||||
|
||||
use exec::CommandTemplate;
|
||||
use internal::{error, pattern_has_uppercase_char, transform_args_with_exec, FdOptions, FileTypes,
|
||||
SizeFilter};
|
||||
use internal::{
|
||||
error, pattern_has_uppercase_char, transform_args_with_exec, FdOptions, FileTypes, SizeFilter,
|
||||
};
|
||||
use lscolors::LsColors;
|
||||
|
||||
fn main() {
|
||||
|
@ -84,7 +85,8 @@ fn main() {
|
|||
}
|
||||
|
||||
// Detect if the user accidentally supplied a path instead of a search pattern
|
||||
if !matches.is_present("full-path") && pattern.contains(std::path::MAIN_SEPARATOR)
|
||||
if !matches.is_present("full-path")
|
||||
&& pattern.contains(std::path::MAIN_SEPARATOR)
|
||||
&& fshelper::is_dir(Path::new(pattern))
|
||||
{
|
||||
error(&format!(
|
||||
|
@ -189,7 +191,8 @@ fn main() {
|
|||
file_types
|
||||
}),
|
||||
extensions: matches.values_of("extension").map(|exts| {
|
||||
let patterns = exts.map(|e| e.trim_left_matches('.'))
|
||||
let patterns = exts
|
||||
.map(|e| e.trim_left_matches('.'))
|
||||
.map(|e| format!(r".\.{}$", regex::escape(e)));
|
||||
match RegexSetBuilder::new(patterns)
|
||||
.case_insensitive(true)
|
||||
|
|
|
@ -105,7 +105,8 @@ fn print_entry_uncolorized(path: &Path, config: &FdOptions) -> io::Result<()> {
|
|||
}
|
||||
|
||||
fn get_path_style<'a>(path: &Path, ls_colors: &'a LsColors) -> Option<&'a ansi_term::Style> {
|
||||
if path.symlink_metadata()
|
||||
if path
|
||||
.symlink_metadata()
|
||||
.map(|md| md.file_type().is_symlink())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
|
@ -118,12 +119,14 @@ fn get_path_style<'a>(path: &Path, ls_colors: &'a LsColors) -> Option<&'a ansi_t
|
|||
Some(&ls_colors.directory)
|
||||
} else if metadata.map(|md| is_executable(&md)).unwrap_or(false) {
|
||||
Some(&ls_colors.executable)
|
||||
} else if let Some(filename_style) = path.file_name()
|
||||
} else if let Some(filename_style) = path
|
||||
.file_name()
|
||||
.and_then(|n| n.to_str())
|
||||
.and_then(|n| ls_colors.filenames.get(n))
|
||||
{
|
||||
Some(filename_style)
|
||||
} else if let Some(extension_style) = path.extension()
|
||||
} else if let Some(extension_style) = path
|
||||
.extension()
|
||||
.and_then(|e| e.to_str())
|
||||
.and_then(|e| ls_colors.extensions.get(e))
|
||||
{
|
||||
|
|
|
@ -224,7 +224,8 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
|||
&& file_types.executables_only)
|
||||
{
|
||||
return ignore::WalkState::Continue;
|
||||
} else if !(entry_type.is_file() || entry_type.is_dir()
|
||||
} else if !(entry_type.is_file()
|
||||
|| entry_type.is_dir()
|
||||
|| entry_type.is_symlink())
|
||||
{
|
||||
// This is probably a block device, char device, fifo or socket. Skip it.
|
||||
|
|
|
@ -120,7 +120,8 @@ fn format_output_error(args: &[&str], expected: &str, actual: &str) -> String {
|
|||
/// Normalize the output for comparison.
|
||||
fn normalize_output(s: &str, trim_left: bool) -> String {
|
||||
// Split into lines and normalize separators.
|
||||
let mut lines = s.replace('\0', "NULL\n")
|
||||
let mut lines = s
|
||||
.replace('\0', "NULL\n")
|
||||
.lines()
|
||||
.map(|line| {
|
||||
let line =
|
||||
|
|
|
@ -33,7 +33,8 @@ static DEFAULT_FILES: &'static [&'static str] = &[
|
|||
];
|
||||
|
||||
fn get_absolute_root_path(env: &TestEnv) -> String {
|
||||
let path = env.test_root()
|
||||
let path = env
|
||||
.test_root()
|
||||
.canonicalize()
|
||||
.expect("absolute path")
|
||||
.to_str()
|
||||
|
|
Loading…
Reference in a new issue