From: "Laurențiu Leahu-Vlăducu" <l.leahu-vladucu@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox] proxmox-router: Improve CLI text output when printing empty lists
Date: Wed, 22 Jan 2025 14:14:00 +0100 [thread overview]
Message-ID: <20250122131400.157635-1-l.leahu-vladucu@proxmox.com> (raw)
CLI tools that use '--output-format text' and print empty lists now
show a 'No results' message. Previously, this was sometimes confusing
because nothing was printed.
Signed-off-by: Laurențiu Leahu-Vlăducu <l.leahu-vladucu@proxmox.com>
---
proxmox-router/src/cli/text_table.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/proxmox-router/src/cli/text_table.rs b/proxmox-router/src/cli/text_table.rs
index 34173b4d..6109d36f 100644
--- a/proxmox-router/src/cli/text_table.rs
+++ b/proxmox-router/src/cli/text_table.rs
@@ -788,7 +788,7 @@ fn extract_one_of_variant_properties(
/// Format data using TableFormatOptions
pub fn value_to_text<W: Write>(
- output: W,
+ mut output: W,
data: &mut Value,
schema: &Schema,
options: &TableFormatOptions,
@@ -820,6 +820,7 @@ pub fn value_to_text<W: Write>(
None => bail!("got unexpected data (expected array)."),
};
if list.is_empty() {
+ output.write_all(b"No results\n")?;
return Ok(());
}
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next reply other threads:[~2025-01-22 13:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 13:14 Laurențiu Leahu-Vlăducu [this message]
2025-01-24 8:26 ` Thomas Lamprecht
2025-01-24 8:58 ` Laurențiu Leahu-Vlăducu
2025-01-24 9:13 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250122131400.157635-1-l.leahu-vladucu@proxmox.com \
--to=l.leahu-vladucu@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox