mirror of https://github.com/sharkdp/fd.git
Updates and preparations for v5.0
This commit is contained in:
parent
15a3ca0c80
commit
e9cf8af911
|
@ -1,6 +1,6 @@
|
|||
[root]
|
||||
name = "fd-find"
|
||||
version = "4.0.0"
|
||||
version = "5.0.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -16,7 +16,7 @@ license = "MIT/Apache-2.0"
|
|||
name = "fd-find"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/sharkdp/fd"
|
||||
version = "4.0.0"
|
||||
version = "5.0.0"
|
||||
|
||||
[[bin]]
|
||||
name = "fd"
|
||||
|
|
|
@ -171,6 +171,7 @@ FLAGS:
|
|||
-H, --hidden Search hidden files and directories
|
||||
-I, --no-ignore Do not respect .(git)ignore files
|
||||
-s, --case-sensitive Case-sensitive search (default: smart case)
|
||||
-i, --ignore-case Case-insensitive search (default: smart case)
|
||||
-a, --absolute-path Show absolute instead of relative paths
|
||||
-L, --follow Follow symbolic links
|
||||
-p, --full-path Search full path (default: file-/dirname only)
|
||||
|
@ -182,10 +183,9 @@ OPTIONS:
|
|||
-d, --max-depth <depth> Set maximum search depth (default: none)
|
||||
-t, --type <filetype> Filter by type: f(ile), d(irectory), (sym)l(ink)
|
||||
-e, --extension <ext> Filter by file extension
|
||||
-c, --color <when> When to use color in the output:
|
||||
never, auto, always (default: auto)
|
||||
-j, --threads <num> Set number of threads to use for searching:
|
||||
(default: number of available CPU cores)
|
||||
-c, --color <when> When to use colors: never, *auto*, always
|
||||
-j, --threads <num> Set number of threads to use for searching & executing
|
||||
-x, --exec <cmd> Execute the given command for each search result
|
||||
|
||||
ARGS:
|
||||
<pattern> the search pattern, a regular expression (optional)
|
||||
|
|
13
src/app.rs
13
src/app.rs
|
@ -103,7 +103,13 @@ pub fn build_app() -> App<'static, 'static> {
|
|||
.takes_value(true)
|
||||
.hidden(true),
|
||||
)
|
||||
.arg(arg("exec").long("exec").short("x").takes_value(true))
|
||||
.arg(
|
||||
arg("exec")
|
||||
.long("exec")
|
||||
.short("x")
|
||||
.takes_value(true)
|
||||
.value_name("cmd"),
|
||||
)
|
||||
.arg(arg("pattern"))
|
||||
.arg(arg("path"))
|
||||
}
|
||||
|
@ -153,9 +159,8 @@ fn usage() -> HashMap<&'static str, Help> {
|
|||
'd' or 'directory': directories\n \
|
||||
'l' or 'symlink': symbolic links");
|
||||
doc!(h, "exec"
|
||||
, "Execute each discovered path using the argument that follows as the command expression."
|
||||
, "Execute each discovered path using the argument that follows as the command \
|
||||
expression.\n \
|
||||
, "Execute the given command for each search result"
|
||||
, "Execute the given command for each search result.\n\
|
||||
The following are valid tokens that can be used within the expression for generating \
|
||||
commands:\n \
|
||||
'{}': places the input in the location of this token\n \
|
||||
|
|
|
@ -38,7 +38,7 @@ pub fn job(
|
|||
drop(lock);
|
||||
// Generate a command to store within the buffer, and execute the command.
|
||||
// Note that the `then_execute()` method will clear the buffer for us.
|
||||
cmd.generate(buffer, &value, out_perm.clone())
|
||||
cmd.generate(buffer, &value, Arc::clone(&out_perm))
|
||||
.then_execute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ lazy_static! {
|
|||
static ref COMMAND: (String, &'static str) = if cfg!(target_os = "windows") {
|
||||
("cmd".into(), "/C")
|
||||
} else {
|
||||
(env::var("SHELL").unwrap_or("/bin/sh".into()), "-c")
|
||||
(env::var("SHELL").unwrap_or_else(|_| "/bin/sh".into()), "-c")
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ fn expr_has_uppercase_char(expr: &Expr) -> bool {
|
|||
r.start.is_uppercase() || r.end.is_uppercase()
|
||||
})
|
||||
}
|
||||
Expr::Group { ref e, .. } => expr_has_uppercase_char(e),
|
||||
Expr::Group { ref e, .. } |
|
||||
Expr::Repeat { ref e, .. } => expr_has_uppercase_char(e),
|
||||
Expr::Concat(ref es) => es.iter().any(expr_has_uppercase_char),
|
||||
Expr::Alternate(ref es) => es.iter().any(expr_has_uppercase_char),
|
||||
|
|
|
@ -17,7 +17,7 @@ pub type ExtensionStyles = HashMap<String, Style>;
|
|||
/// Maps filenames to ANSI colors / styles.
|
||||
pub type FilenameStyles = HashMap<String, Style>;
|
||||
|
||||
const LS_CODES: &'static [&'static str] = &[
|
||||
const LS_CODES: &[&str] = &[
|
||||
"no",
|
||||
"no",
|
||||
"fi",
|
||||
|
|
|
@ -52,7 +52,7 @@ fn main() {
|
|||
|
||||
// Get the current working directory
|
||||
let current_dir = Path::new(".");
|
||||
if !fshelper::is_dir(¤t_dir) {
|
||||
if !fshelper::is_dir(current_dir) {
|
||||
error("Error: could not get current directory.");
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ fn main() {
|
|||
None
|
||||
};
|
||||
|
||||
let command = matches.value_of("exec").map(|x| TokenizedCommand::new(&x));
|
||||
let command = matches.value_of("exec").map(|x| TokenizedCommand::new(x));
|
||||
|
||||
let config = FdOptions {
|
||||
case_sensitive,
|
||||
|
|
10
src/walk.rs
10
src/walk.rs
|
@ -76,9 +76,9 @@ pub fn scan(root: &Path, pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
|||
// Each spawned job will store it's thread handle in here.
|
||||
let mut handles = Vec::with_capacity(threads);
|
||||
for _ in 0..threads {
|
||||
let rx = shared_rx.clone();
|
||||
let cmd = cmd.clone();
|
||||
let out_perm = out_perm.clone();
|
||||
let rx = Arc::clone(&shared_rx);
|
||||
let cmd = Arc::clone(&cmd);
|
||||
let out_perm = Arc::clone(&out_perm);
|
||||
|
||||
// Spawn a job thread that will listen for and execute inputs.
|
||||
let handle = thread::spawn(move || exec::job(rx, cmd, out_perm));
|
||||
|
@ -113,7 +113,7 @@ pub fn scan(root: &Path, pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
|||
if time::Instant::now() - start > max_buffer_time {
|
||||
// Flush the buffer
|
||||
for v in &buffer {
|
||||
output::print_entry(&v, &rx_config);
|
||||
output::print_entry(v, &rx_config);
|
||||
}
|
||||
buffer.clear();
|
||||
|
||||
|
@ -188,7 +188,7 @@ pub fn scan(root: &Path, pattern: Arc<Regex>, config: Arc<FdOptions>) {
|
|||
}
|
||||
|
||||
let search_str_o = if config.search_full_path {
|
||||
match fshelper::path_absolute_form(&entry_path) {
|
||||
match fshelper::path_absolute_form(entry_path) {
|
||||
Ok(path_abs_buf) => Some(path_abs_buf.to_string_lossy().into_owned().into()),
|
||||
Err(_) => error("Error: unable to get full path."),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue