mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-17 09:28:25 +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::mpsc::Receiver;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
use crate::config::Config;
|
||||||
use crate::error::print_error;
|
use crate::error::print_error;
|
||||||
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||||
use crate::walk::WorkerResult;
|
|
||||||
use crate::filesystem::strip_current_dir;
|
use crate::filesystem::strip_current_dir;
|
||||||
use crate::config::Config;
|
use crate::walk::WorkerResult;
|
||||||
|
|
||||||
use super::CommandTemplate;
|
use super::CommandTemplate;
|
||||||
|
|
||||||
|
@ -60,7 +60,9 @@ pub fn batch(
|
||||||
buffer_output: bool,
|
buffer_output: bool,
|
||||||
config: &Arc<Config>,
|
config: &Arc<Config>,
|
||||||
) -> ExitCode {
|
) -> ExitCode {
|
||||||
let paths = rx.iter().filter_map(|value| match value {
|
let paths = rx
|
||||||
|
.iter()
|
||||||
|
.filter_map(|value| match value {
|
||||||
WorkerResult::Entry(val) => Some(val),
|
WorkerResult::Entry(val) => Some(val),
|
||||||
WorkerResult::Error(err) => {
|
WorkerResult::Error(err) => {
|
||||||
if show_filesystem_errors {
|
if show_filesystem_errors {
|
||||||
|
|
|
@ -144,7 +144,6 @@ impl CommandTemplate {
|
||||||
out_perm: Arc<Mutex<()>>,
|
out_perm: Arc<Mutex<()>>,
|
||||||
buffer_output: bool,
|
buffer_output: bool,
|
||||||
) -> ExitCode {
|
) -> ExitCode {
|
||||||
|
|
||||||
let mut cmd = Command::new(self.args[0].generate(&input, self.path_separator.as_deref()));
|
let mut cmd = Command::new(self.args[0].generate(&input, self.path_separator.as_deref()));
|
||||||
for arg in &self.args[1..] {
|
for arg in &self.args[1..] {
|
||||||
cmd.arg(arg.generate(&input, self.path_separator.as_deref()));
|
cmd.arg(arg.generate(&input, self.path_separator.as_deref()));
|
||||||
|
|
|
@ -179,7 +179,13 @@ fn spawn_receiver(
|
||||||
// This will be set to `Some` if the `--exec` argument was supplied.
|
// This will be set to `Some` if the `--exec` argument was supplied.
|
||||||
if let Some(ref cmd) = config.command {
|
if let Some(ref cmd) = config.command {
|
||||||
if cmd.in_batch_mode() {
|
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 {
|
} else {
|
||||||
let shared_rx = Arc::new(Mutex::new(rx));
|
let shared_rx = Arc::new(Mutex::new(rx));
|
||||||
|
|
||||||
|
|
|
@ -1944,6 +1944,6 @@ fn test_no_strip() {
|
||||||
|
|
||||||
te.assert_output(
|
te.assert_output(
|
||||||
&["c.foo", "./", "-X", "echo"],
|
&["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