[pve-devel] [PATCH common] PVE::CLIHandler::print_text_table: use eq for $sort_key

Stoiko Ivanov s.ivanov at proxmox.com
Tue Jun 26 15:38:48 CEST 2018


Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
I like the codechanges in the 2 patches! - it's shorter and more clear than the
previous version. - Thanks!

One tiny thing which bit me, while trying it with the pveum changes was, that
providing a prop as $sort_key resulted in a warning - see this fixup.

One cosmetic change to before, is that getting rid of the special treatment for
the last column now adds quite some whitespace in the end of lines, where one
entry in data is very long, when compared to the others. (pveum role list was
my example) resulting in some unexpected newlines. (I would provide a follow-up
unless there is a strong preference for the current version).

We now also print one extra space before each newline - however, given that
this output is more for visual representation, than for automated parsing I'm
fine with it.

src/PVE/CLIHandler.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
index d7d1ce4..db03544 100644
--- a/src/PVE/CLIHandler.pm
+++ b/src/PVE/CLIHandler.pm
@@ -452,7 +452,7 @@ sub print_text_table {
     my ($data, $returnprops, $props_to_print, $sort_key) = @_;
 
     my $autosort = 0;
-    if (defined($sort_key) && ($sort_key == 1)) {
+    if (defined($sort_key) && ($sort_key eq 1)) {
 	$autosort = 1;
 	$sort_key = undef;
     }
-- 
2.11.0




More information about the pve-devel mailing list