[pve-devel] applied: [PATCH qemu-server] qm showcmd: add simple 'pretty' parameter

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Jan 10 15:51:16 CET 2018


applied and added another commit to indent new lines by 2 spaces:
-	$cmdline =~ s/ -/ \\\n-/g if $param->{pretty};
+	$cmdline =~ s/ -/ \\\n  -/g if $param->{pretty};

Now I can drop my sed wrapper ;-)

On Tue, Jan 09, 2018 at 09:56:28AM +0100, Thomas Lamprecht wrote:
> Shows each parameter value pair in a new line with a backslash at the
> end, so it's still possible to copy, paste and execute it, while
> being easier to read and edit by humans. This is opt in.
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  PVE/CLI/qm.pm | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
> index 7db65d3..191f41e 100755
> --- a/PVE/CLI/qm.pm
> +++ b/PVE/CLI/qm.pm
> @@ -117,6 +117,12 @@ __PACKAGE__->register_method ({
>  	additionalProperties => 0,
>  	properties => {
>  	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
> +	    pretty => {
> +		description => "Puts each option on a new line to enhance human readability",
> +		type => 'boolean',
> +		optional => 1,
> +		default => 0,
> +	    }
>  	},
>      },
>      returns => { type => 'null'},
> @@ -124,7 +130,11 @@ __PACKAGE__->register_method ({
>  	my ($param) = @_;
>  
>  	my $storecfg = PVE::Storage::config();
> -	print PVE::QemuServer::vm_commandline($storecfg, $param->{vmid}) . "\n";
> +	my $cmdline = PVE::QemuServer::vm_commandline($storecfg, $param->{vmid});
> +
> +	$cmdline =~ s/ -/ \\\n-/g if $param->{pretty};
> +
> +	print "$cmdline\n";
>  
>  	return undef;
>      }});
> -- 
> 2.11.0




More information about the pve-devel mailing list