[pve-devel] [pve-common 2/3] output format options: remove 'plain', add 'json-pretty'

Dietmar Maurer dietmar at proxmox.com
Tue Jul 10 13:43:04 CEST 2018


Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 src/PVE/CLIFormatter.pm | 5 ++++-
 src/PVE/JSONSchema.pm   | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm
index 043ce49..927e5a6 100644
--- a/src/PVE/CLIFormatter.pm
+++ b/src/PVE/CLIFormatter.pm
@@ -380,8 +380,11 @@ sub print_api_result {
 
     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 });
-    } 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') {
diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index aa82167..c9a9b1e 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -108,7 +108,7 @@ register_standard_option('fingerprint-sha256', {
 register_standard_option('pve-output-format', {
     type => 'string',
     description => 'Output format.',
-    enum => [ 'text', 'plain', 'json' ],
+    enum => [ 'text', 'json', 'json-pretty' ],
     optional => 1,
     default => 'text',
 });
-- 
2.11.0




More information about the pve-devel mailing list