* [pbs-devel] [PATCH proxmox] proxmox-router: Improve CLI text output when printing empty lists
@ 2025-01-22 13:14 Laurențiu Leahu-Vlăducu
2025-01-24 8:26 ` Thomas Lamprecht
0 siblings, 1 reply; 4+ messages in thread
From: Laurențiu Leahu-Vlăducu @ 2025-01-22 13:14 UTC (permalink / raw)
To: pbs-devel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pbs-devel] [PATCH proxmox] proxmox-router: Improve CLI text output when printing empty lists
2025-01-22 13:14 [pbs-devel] [PATCH proxmox] proxmox-router: Improve CLI text output when printing empty lists Laurențiu Leahu-Vlăducu
@ 2025-01-24 8:26 ` Thomas Lamprecht
2025-01-24 8:58 ` Laurențiu Leahu-Vlăducu
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Lamprecht @ 2025-01-24 8:26 UTC (permalink / raw)
To: Proxmox Backup Server development discussion,
Laurențiu Leahu-Vlăducu
Am 22.01.25 um 14:14 schrieb Laurențiu Leahu-Vlăducu:
> 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.
I get where you come from with this but "No result" might be interpreted
as error-like message by some though?
And not sure how popular such an approach is, most standard CLI tools
do not print anything if the result is empty, e.g. `ls` on an emtpy dir
also outputs nothing. Are there any user requests/feedback on this?
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pbs-devel] [PATCH proxmox] proxmox-router: Improve CLI text output when printing empty lists
2025-01-24 8:26 ` Thomas Lamprecht
@ 2025-01-24 8:58 ` Laurențiu Leahu-Vlăducu
2025-01-24 9:13 ` Thomas Lamprecht
0 siblings, 1 reply; 4+ messages in thread
From: Laurențiu Leahu-Vlăducu @ 2025-01-24 8:58 UTC (permalink / raw)
To: Thomas Lamprecht, Proxmox Backup Server development discussion
On 24.01.25 09:26, Thomas Lamprecht wrote:
> Am 22.01.25 um 14:14 schrieb Laurențiu Leahu-Vlăducu:
>> 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.
>
> I get where you come from with this but "No result" might be interpreted
> as error-like message by some though?
I am open to suggestions about the error message :) I was also not 100%
sure what the best message could be (especially one that shouldn't sound
like an error). I would have preferred to have something more specific
(e.g. "No tape drives found", but since this is a general formatter, I
cannot do that (at least not without adding additional parameters, which
is not worth it for this use case, IMO).
> And not sure how popular such an approach is, most standard CLI tools
> do not print anything if the result is empty, e.g. `ls` on an emtpy dir
> also outputs nothing. Are there any user requests/feedback on this?
Not that I know. This was kind of my own request, because I wrote some
docs on PBS tape backups and thought: if the user never used tape
drives/changers and is unsure whether they have been detected correctly,
they might try "proxmox-tape drive scan" or "proxmox-tape changer scan"
(or "list"), and if nothing is found, there is no output. Now, if the
user knows what the output should look like (a table with
drives/changers), it may be obvious that an empty output means that
proxmox-tape found nothing. But if the user never used PBS or tapes
before, or if that happened a long time ago, it might be unclear why
there is no output. Thus showing no output for "proxmox-tape drive scan"
makes it unclear whether this is an error or just empty.
I agree with you that printing something like "No result" makes it
inconsistent with other CLI tools. On the other hand, at least when
talking about tape drives/changers that require drivers and hardware
detection, it's nice to have some further details on what is happening
"behind the scenes".
Another argument in favor of it is that using --output-format json or
json-pretty also shows an empty list [], making it clearer that it's not
an error.
Just some of my thoughts ;) I know that this is a general formatter and
not related to proxmox-tape, but I thought it could make sense in other
Proxmox CLI tools as well.
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [pbs-devel] [PATCH proxmox] proxmox-router: Improve CLI text output when printing empty lists
2025-01-24 8:58 ` Laurențiu Leahu-Vlăducu
@ 2025-01-24 9:13 ` Thomas Lamprecht
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2025-01-24 9:13 UTC (permalink / raw)
To: Proxmox Backup Server development discussion,
Laurențiu Leahu-Vlăducu
Am 24.01.25 um 09:58 schrieb Laurențiu Leahu-Vlăducu:
> On 24.01.25 09:26, Thomas Lamprecht wrote:
>> Am 22.01.25 um 14:14 schrieb Laurențiu Leahu-Vlăducu:
>>> 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.
>>
>> I get where you come from with this but "No result" might be interpreted
>> as error-like message by some though?
>
> I am open to suggestions about the error message :) I was also not 100%
> sure what the best message could be (especially one that shouldn't sound
> like an error). I would have preferred to have something more specific
> (e.g. "No tape drives found", but since this is a general formatter, I
> cannot do that (at least not without adding additional parameters, which
> is not worth it for this use case, IMO).
>
>> And not sure how popular such an approach is, most standard CLI tools
>> do not print anything if the result is empty, e.g. `ls` on an emtpy dir
>> also outputs nothing. Are there any user requests/feedback on this?
>
> Not that I know. This was kind of my own request, because I wrote some
> docs on PBS tape backups and thought: if the user never used tape
> drives/changers and is unsure whether they have been detected correctly,
> they might try "proxmox-tape drive scan" or "proxmox-tape changer scan"
> (or "list"), and if nothing is found, there is no output. Now, if the
> user knows what the output should look like (a table with
> drives/changers), it may be obvious that an empty output means that
> proxmox-tape found nothing. But if the user never used PBS or tapes
> before, or if that happened a long time ago, it might be unclear why
> there is no output. Thus showing no output for "proxmox-tape drive scan"
> makes it unclear whether this is an error or just empty.
IMO gettingh "No result" when scanning for tape changers/drives is not
really helpful in improving UX; an explicit "No changer found" and
"No drive found" might be indeed helpful, as those have actually context
and tell the user really what's going on.
Besides that, "empty result" != "no result", often there was a result,
it's just empty. Finding some generalized wording here that fits all
is IMO rather close to impossible, at least it would definitively make
UX a tiny bit worse in quite a few CLI endpoints.
> I agree with you that printing something like "No result" makes it
> inconsistent with other CLI tools. On the other hand, at least when
> talking about tape drives/changers that require drivers and hardware
> detection, it's nice to have some further details on what is happening
> "behind the scenes".
>
> Another argument in favor of it is that using --output-format json or
> json-pretty also shows an empty list [], making it clearer that it's not
> an error.
I do not think that's comparable, those formats have a defined serialization
for empty lists, text hasn't. And personally I like being able to test
for an empty string in combination with exit-code being zero in simple
scripts, i.e. where JSON et al. is rather overkill, to tell if a listing
is empty.
> Just some of my thoughts ;) I know that this is a general formatter and
> not related to proxmox-tape, but I thought it could make sense in other
> Proxmox CLI tools as well.
I'd either do this in the specific commands that have more complex
interactions like scanning for some HW, and not just get some info or
list some content, where an empty result is fine.
A tradeoff could be to add plumbing to the CLI code to allow defining
such a message from inside the actual CLI executable code, that then
gets automatically printed if the output-format is text and there is no
result. Really not sure if that's worth it though.
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-24 9:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-22 13:14 [pbs-devel] [PATCH proxmox] proxmox-router: Improve CLI text output when printing empty lists Laurențiu Leahu-Vlăducu
2025-01-24 8:26 ` Thomas Lamprecht
2025-01-24 8:58 ` Laurențiu Leahu-Vlăducu
2025-01-24 9:13 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox