[pve-devel] applied: [pve-common v2 00/11] CLIFormatter improvements

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Jun 29 14:51:16 CEST 2018


On 6/29/18 1:15 PM, Dietmar Maurer wrote:
> more features to render nice ascii/utf8 tables + cleanups
> 
> Changes in V2:
> 
> - add/use new encoding option
> - query_terminal_options - new helper
> - never render undefined values
> - support multiline data
> - cleanups
> 
> Dietmar Maurer (11):
>   cli: print_text_table: allow to draw ascii art borders
>   cli: print_api_result: use print_api_list to print objects
>   PVE::JSONSchema::register_renderer - allow to register renderers by
>     name
>   cli: data_to_text: pass property info
>   cli: print_text_table: allow to limit output width
>   CLIFormatter: pass options as hash
>   CLIFormatter: implement tables with utf8 borders
>   cli: print_api_result: add/use new encoding option
>   PVE::CLIFormatter::query_terminal_options - new helper
>   cli: data_to_text: never render undefined values
>   cli: print_text_table: support multiline data
> 
>  src/PVE/CLIFormatter.pm | 233 ++++++++++++++++++++++++++++++++++++++++--------
>  src/PVE/JSONSchema.pm   |  16 ++++
>  2 files changed, 214 insertions(+), 35 deletions(-)
> 

applied, with followup to restore autosort behavior again:


diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm
index 824c1a2..b50464d 100644
--- a/src/PVE/CLIFormatter.pm
+++ b/src/PVE/CLIFormatter.pm
@@ -75,9 +75,7 @@ sub print_text_table {
     my $utf8 = $options->{utf8};
     my $encoding = $options->{encoding} // 'UTF-8';

-    my $autosort = 1;
-    if (defined($sort_key) && $sort_key eq 0) {
-       $autosort = 0;
+    if (!defined($sort_key) || $sort_key eq 0) {
        $sort_key = $props_to_print->[0];
     }




More information about the pve-devel mailing list