mirror of
https://github.com/bootandy/dust.git
synced 2025-12-05 20:40:11 -08:00
feat: Return 1 if no dirs are found
A better error code
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -307,8 +307,12 @@ fn main() {
|
||||
indicator.stop();
|
||||
|
||||
let print_errors = config.get_print_errors(&options);
|
||||
print_any_errors(print_errors, walk_data.errors);
|
||||
let final_errors = walk_data.errors.lock().unwrap();
|
||||
print_any_errors(print_errors, &final_errors);
|
||||
|
||||
if tree.children.is_empty() && !final_errors.file_not_found.is_empty() {
|
||||
std::process::exit(1)
|
||||
} else {
|
||||
print_output(
|
||||
config,
|
||||
options,
|
||||
@@ -317,6 +321,7 @@ fn main() {
|
||||
is_colors,
|
||||
terminal_width,
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -357,8 +362,7 @@ fn print_output(
|
||||
}
|
||||
}
|
||||
|
||||
fn print_any_errors(print_errors: bool, errors: Arc<Mutex<RuntimeErrors>>) {
|
||||
let final_errors = errors.lock().unwrap();
|
||||
fn print_any_errors(print_errors: bool, final_errors: &RuntimeErrors) {
|
||||
if !final_errors.file_not_found.is_empty() {
|
||||
let err = final_errors
|
||||
.file_not_found
|
||||
|
||||
@@ -107,7 +107,9 @@ pub fn test_ignore_all_in_file() {
|
||||
#[test]
|
||||
pub fn test_with_bad_param() {
|
||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||
let result = cmd.arg("bad_place").unwrap();
|
||||
cmd.arg("-P").arg("bad_place");
|
||||
let output_error = cmd.unwrap_err();
|
||||
let result = output_error.as_output().unwrap();
|
||||
let stderr = str::from_utf8(&result.stderr).unwrap();
|
||||
assert!(stderr.contains("No such file or directory"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user