]> git.proxmox.com Git - qemu-server.git/commitdiff
qm showcmd: add simple 'pretty' parameter
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 9 Jan 2018 08:56:28 +0000 (09:56 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 10 Jan 2018 14:47:05 +0000 (15:47 +0100)
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@proxmox.com>
PVE/CLI/qm.pm

index 7db65d36a737e71f832b34f6d422195a7014a298..687618a905ac8968b386d10784b14358c2a18242 100755 (executable)
@@ -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;
     }});