mirror of
https://github.com/sharkdp/bat.git
synced 2025-03-14 06:38:24 +00:00
Continue with output after "is directory"-error
This commit is contained in:
parent
eee7e5a575
commit
278bde5cee
@ -26,20 +26,30 @@ impl<'b> Controller<'b> {
|
|||||||
let stdin = io::stdin();
|
let stdin = io::stdin();
|
||||||
|
|
||||||
for input_file in &self.config.files {
|
for input_file in &self.config.files {
|
||||||
let mut reader = input_file.get_reader(&stdin)?;
|
match input_file.get_reader(&stdin) {
|
||||||
|
Err(error) => {
|
||||||
|
handle_error(&error);
|
||||||
|
no_errors = false;
|
||||||
|
}
|
||||||
|
Ok(mut reader) => {
|
||||||
|
let result = if self.config.loop_through {
|
||||||
|
let mut printer = SimplePrinter::new();
|
||||||
|
self.print_file(reader, &mut printer, writer, *input_file)
|
||||||
|
} else {
|
||||||
|
let mut printer = InteractivePrinter::new(
|
||||||
|
&self.config,
|
||||||
|
&self.assets,
|
||||||
|
*input_file,
|
||||||
|
&mut reader,
|
||||||
|
);
|
||||||
|
self.print_file(reader, &mut printer, writer, *input_file)
|
||||||
|
};
|
||||||
|
|
||||||
let result = if self.config.loop_through {
|
if let Err(error) = result {
|
||||||
let mut printer = SimplePrinter::new();
|
handle_error(&error);
|
||||||
self.print_file(reader, &mut printer, writer, *input_file)
|
no_errors = false;
|
||||||
} else {
|
}
|
||||||
let mut printer =
|
}
|
||||||
InteractivePrinter::new(&self.config, &self.assets, *input_file, &mut reader);
|
|
||||||
self.print_file(reader, &mut printer, writer, *input_file)
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Err(error) = result {
|
|
||||||
handle_error(&error);
|
|
||||||
no_errors = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,3 +102,13 @@ fn fail_non_existing() {
|
|||||||
fn fail_directory() {
|
fn fail_directory() {
|
||||||
bat().arg("sub_directory").assert().failure();
|
bat().arg("sub_directory").assert().failure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn do_not_exit_directory() {
|
||||||
|
bat()
|
||||||
|
.arg("sub_directory")
|
||||||
|
.arg("test.txt")
|
||||||
|
.assert()
|
||||||
|
.stdout("hello world\n")
|
||||||
|
.failure();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user