report: add extra newline between files of directory output

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-11-28 12:25:01 +01:00
parent 5736fa917c
commit 460c3d1619

View File

@ -134,6 +134,7 @@ fn get_directory_content(path: impl AsRef<Path>) -> String {
} }
}; };
let mut out = String::new(); let mut out = String::new();
let mut first = true;
for entry in read_dir_iter { for entry in read_dir_iter {
let entry = match entry { let entry = match entry {
Ok(entry) => entry, Ok(entry) => entry,
@ -144,7 +145,12 @@ fn get_directory_content(path: impl AsRef<Path>) -> String {
}; };
let path = entry.path(); let path = entry.path();
if path.is_file() { if path.is_file() {
if first {
let _ = writeln!(out, "{}", get_file_content(path)); let _ = writeln!(out, "{}", get_file_content(path));
first = false;
} else {
let _ = writeln!(out, "\n{}", get_file_content(path));
}
} else { } else {
let _ = writeln!(out, "skipping sub-directory `{}`", path.display()); let _ = writeln!(out, "skipping sub-directory `{}`", path.display());
} }