]> git.proxmox.com Git - pve-common.git/commitdiff
output format options: remove 'plain', add 'json-pretty'
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 10 Jul 2018 11:51:27 +0000 (13:51 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 10 Jul 2018 11:52:20 +0000 (13:52 +0200)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
src/PVE/CLIFormatter.pm
src/PVE/JSONSchema.pm

index 043ce49d3515a7cdae3e1702b704dbd2cab84c87..927e5a6449dc3773987765c8fb4beaab02bb4cd4 100644 (file)
@@ -379,9 +379,12 @@ sub print_api_result {
     return if $result_schema->{type} eq 'null';
 
     if ($format eq 'json') {
     return if $result_schema->{type} eq 'null';
 
     if ($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, pretty => 1 });
        # Note: we always use utf8 encoding for json format
        print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1, pretty => 1 });
-    } elsif ($format eq 'text' || $format eq 'plain') {
+    } elsif ($format eq 'text') {
        my $encoding = $options->{encoding} // 'UTF-8';
        my $type = $result_schema->{type};
        if ($type eq 'object') {
        my $encoding = $options->{encoding} // 'UTF-8';
        my $type = $result_schema->{type};
        if ($type eq 'object') {
index aa82167346b052ecbff30596d89bf92e382e3ce0..c9a9b1e69c003c2e4f17ac28184e42d40fda4bbb 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', 'plain', 'json' ],
+    enum => [ 'text', 'json', 'json-pretty' ],
     optional => 1,
     default => 'text',
 });
     optional => 1,
     default => 'text',
 });