Print warning on empty content

closes #107
closes #108
This commit is contained in:
sharkdp authored and David Peter committed 2020-10-30 21:58:02 +01:00
1 parent d9723592bf
commit b1c8606918
3 files changed
+32

No files matched your search

+3
View File
@@ -428,8 +428,10 @@ impl<'a, Writer: Write> Printer<'a, Writer> {
// Finish last line
self.print_textline().ok();
if !self.header_was_printed() {
self.header();
writeln!(self.writer, "│ │ No content to print │ │ │ │").ok();
}
self.footer();
@@ -459,6 +461,7 @@ mod tests {
let input = io::empty();
let expected_string = "\
┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐
│ │ No content to print │ │ │ │
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘
"
.to_owned();
View File
Whitespace-only changes.
+29
View File
@@ -41,6 +41,35 @@ fn length_restricts_output_size() {
);
}
#[test]
fn prints_warning_on_empty_content() {
hexyl()
.arg("empty")
.arg("--color=never")
.assert()
.success()
.stdout(
"┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\
│ │ No content to print │ │ │ │\n\
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n",
);
}
#[test]
fn prints_warning_when_skipping_past_the_end() {
hexyl()
.arg("ascii")
.arg("--color=never")
.arg("--skip=1000")
.assert()
.success()
.stdout(
"┌────────┬─────────────────────────┬─────────────────────────┬────────┬────────┐\n\
│ │ No content to print │ │ │ │\n\
└────────┴─────────────────────────┴─────────────────────────┴────────┴────────┘\n",
);
}
#[test]
fn fail_if_length_and_bytes_options_are_used_simultaneously() {
hexyl()