]> git.proxmox.com Git - pve-common.git/commitdiff
introcude new output format 'yaml'
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 26 Jul 2018 10:02:45 +0000 (12:02 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 26 Jul 2018 10:02:45 +0000 (12:02 +0200)
src/PVE/CLIFormatter.pm
src/PVE/JSONSchema.pm

index 61b313b082cea524386a22a6ea13553a0e2f6987..f6ad45921842c827504ddcd7d738d6d472a54f4d 100644 (file)
@@ -389,7 +389,9 @@ sub print_api_result {
 
     return if $result_schema->{type} eq 'null';
 
 
     return if $result_schema->{type} eq 'null';
 
-    if ($format eq 'json') {
+    if ($format eq 'yaml') {
+       print encode('UTF-8', CPAN::Meta::YAML::Dump($data));
+    } elsif ($format eq 'json') {
        # Note: we always use utf8 encoding for json format
        print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1 }) . "\n";
     } elsif ($format eq 'json-pretty') {
        # Note: we always use utf8 encoding for json format
        print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1 }) . "\n";
     } elsif ($format eq 'json-pretty') {
index c9a9b1e69c003c2e4f17ac28184e42d40fda4bbb..06c500f0554bd491735a6137bf3c22f4880b733e 100644 (file)
@@ -108,7 +108,7 @@ register_standard_option('fingerprint-sha256', {
 register_standard_option('pve-output-format', {
     type => 'string',
     description => 'Output format.',
 register_standard_option('pve-output-format', {
     type => 'string',
     description => 'Output format.',
-    enum => [ 'text', 'json', 'json-pretty' ],
+    enum => [ 'text', 'json', 'json-pretty', 'yaml' ],
     optional => 1,
     default => 'text',
 });
     optional => 1,
     default => 'text',
 });