mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 01:18:26 +01:00
fmt
This commit is contained in:
parent
a4a4709320
commit
91860bf682
5 changed files with 28 additions and 21 deletions
|
@ -2,11 +2,11 @@ use std::path::PathBuf;
|
|||
use std::sync::mpsc::Receiver;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::error::print_error;
|
||||
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||
use crate::walk::WorkerResult;
|
||||
use crate::filesystem::strip_current_dir;
|
||||
use crate::config::Config;
|
||||
use crate::walk::WorkerResult;
|
||||
|
||||
use super::CommandTemplate;
|
||||
|
||||
|
@ -60,21 +60,23 @@ pub fn batch(
|
|||
buffer_output: bool,
|
||||
config: &Arc<Config>,
|
||||
) -> ExitCode {
|
||||
let paths = rx.iter().filter_map(|value| match value {
|
||||
WorkerResult::Entry(val) => Some(val),
|
||||
WorkerResult::Error(err) => {
|
||||
if show_filesystem_errors {
|
||||
print_error(err.to_string());
|
||||
let paths = rx
|
||||
.iter()
|
||||
.filter_map(|value| match value {
|
||||
WorkerResult::Entry(val) => Some(val),
|
||||
WorkerResult::Error(err) => {
|
||||
if show_filesystem_errors {
|
||||
print_error(err.to_string());
|
||||
}
|
||||
None
|
||||
}
|
||||
None
|
||||
}
|
||||
})
|
||||
.map(|m| {
|
||||
if config.no_strip {
|
||||
m
|
||||
} else {
|
||||
strip_current_dir(&m).to_path_buf()
|
||||
}
|
||||
});
|
||||
})
|
||||
.map(|m| {
|
||||
if config.no_strip {
|
||||
m
|
||||
} else {
|
||||
strip_current_dir(&m).to_path_buf()
|
||||
}
|
||||
});
|
||||
cmd.generate_and_execute_batch(paths, buffer_output)
|
||||
}
|
||||
|
|
|
@ -144,7 +144,6 @@ impl CommandTemplate {
|
|||
out_perm: Arc<Mutex<()>>,
|
||||
buffer_output: bool,
|
||||
) -> ExitCode {
|
||||
|
||||
let mut cmd = Command::new(self.args[0].generate(&input, self.path_separator.as_deref()));
|
||||
for arg in &self.args[1..] {
|
||||
cmd.arg(arg.generate(&input, self.path_separator.as_deref()));
|
||||
|
|
|
@ -376,7 +376,7 @@ fn construct_config(matches: clap::ArgMatches, pattern_regex: &str) -> Result<Co
|
|||
}
|
||||
}),
|
||||
no_strip: matches.is_present("path") || matches.is_present("search-path"),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn extract_command(
|
||||
|
|
|
@ -179,7 +179,13 @@ fn spawn_receiver(
|
|||
// This will be set to `Some` if the `--exec` argument was supplied.
|
||||
if let Some(ref cmd) = config.command {
|
||||
if cmd.in_batch_mode() {
|
||||
exec::batch(rx, cmd, show_filesystem_errors, enable_output_buffering, &config)
|
||||
exec::batch(
|
||||
rx,
|
||||
cmd,
|
||||
show_filesystem_errors,
|
||||
enable_output_buffering,
|
||||
&config,
|
||||
)
|
||||
} else {
|
||||
let shared_rx = Arc::new(Mutex::new(rx));
|
||||
|
||||
|
|
|
@ -1944,6 +1944,6 @@ fn test_no_strip() {
|
|||
|
||||
te.assert_output(
|
||||
&["c.foo", "./", "-X", "echo"],
|
||||
"./one/two/C.Foo2 ./one/two/c.foo"
|
||||
"./one/two/C.Foo2 ./one/two/c.foo",
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue