[pve-devel] applied: [pve-common v2] print_api_result_plain: new helper

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Jul 30 16:03:21 CEST 2018


Am 07/27/2018 um 03:22 PM schrieb Dietmar Maurer:
> Usefull to print result without borders an headers.
> 
> Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
> ---
> 
> changes in v2: ignore all terminal options
> 
>   src/PVE/CLIFormatter.pm | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm
> index d964b51..2a2ff30 100644
> --- a/src/PVE/CLIFormatter.pm
> +++ b/src/PVE/CLIFormatter.pm
> @@ -436,4 +436,16 @@ sub print_api_result {
>       }
>   }
>   
> +sub print_api_result_plain {
> +    my ($data, $result_schema, $props_to_print, $options) = @_;
> +
> +    # avoid borders and header, ignore terminal width
> +    $options = $options ? { %$options } : {}; # copy
> +
> +    $options->{noheader} //= 1;
> +    $options->{noborder} //= 1;
> +
> +    print_api_result($data, $result_schema, $props_to_print, $options, {});
> +}
> +
>   1;
> 

applied




More information about the pve-devel mailing list