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:
26
src/main.rs
26
src/main.rs
@@ -307,16 +307,21 @@ fn main() {
|
|||||||
indicator.stop();
|
indicator.stop();
|
||||||
|
|
||||||
let print_errors = config.get_print_errors(&options);
|
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);
|
||||||
|
|
||||||
print_output(
|
if tree.children.is_empty() && !final_errors.file_not_found.is_empty() {
|
||||||
config,
|
std::process::exit(1)
|
||||||
options,
|
} else {
|
||||||
tree,
|
print_output(
|
||||||
walk_data.by_filecount,
|
config,
|
||||||
is_colors,
|
options,
|
||||||
terminal_width,
|
tree,
|
||||||
)
|
walk_data.by_filecount,
|
||||||
|
is_colors,
|
||||||
|
terminal_width,
|
||||||
|
)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,8 +362,7 @@ fn print_output(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_any_errors(print_errors: bool, errors: Arc<Mutex<RuntimeErrors>>) {
|
fn print_any_errors(print_errors: bool, final_errors: &RuntimeErrors) {
|
||||||
let final_errors = errors.lock().unwrap();
|
|
||||||
if !final_errors.file_not_found.is_empty() {
|
if !final_errors.file_not_found.is_empty() {
|
||||||
let err = final_errors
|
let err = final_errors
|
||||||
.file_not_found
|
.file_not_found
|
||||||
|
|||||||
@@ -107,7 +107,9 @@ pub fn test_ignore_all_in_file() {
|
|||||||
#[test]
|
#[test]
|
||||||
pub fn test_with_bad_param() {
|
pub fn test_with_bad_param() {
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
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();
|
let stderr = str::from_utf8(&result.stderr).unwrap();
|
||||||
assert!(stderr.contains("No such file or directory"));
|
assert!(stderr.contains("No such file or directory"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user