Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Sep 27, 2018
1 parent 53226f8 commit 27caa33
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 25 deletions.
45 changes: 30 additions & 15 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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")
Expand All @@ -95,66 +100,76 @@ 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")
.multiple(true)
.number_of_values(1)
.takes_value(true)
.value_name("ext"),
).arg(
)
.arg(
arg("exec")
.long("exec")
.short("x")
.min_values(1)
.allow_hyphen_values(true)
.value_terminator(";")
.value_name("cmd"),
).arg(
)
.arg(
arg("exclude")
.long("exclude")
.short("E")
.takes_value(true)
.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")
.takes_value(true)
.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")
.takes_value(true)
.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))
}

Expand Down
3 changes: 2 additions & 1 deletion src/fshelper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
15 changes: 10 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ fn main() {
));
}
path_buffer
}).collect::<Vec<_>>(),
})
.collect::<Vec<_>>(),
None => vec![current_dir.to_path_buf()],
};

Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
),
}
}
3 changes: 2 additions & 1 deletion src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions tests/testenv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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());

Expand Down
3 changes: 2 additions & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_�invalid.txt");

Expand Down

0 comments on commit 27caa33

Please sign in to comment.