]> source.dussan.org Git - nextcloud-server.git/commitdiff
Replace print_r() with pretty json
authorJoas Schilling <nickvergessen@owncloud.com>
Thu, 9 Apr 2015 12:42:44 +0000 (14:42 +0200)
committerJoas Schilling <nickvergessen@owncloud.com>
Thu, 9 Apr 2015 12:42:44 +0000 (14:42 +0200)
core/command/base.php

index 7e139636b63f1f229acc42865f9dbc2d7f6f8309..b43022a550c567258478283b303088f0bbf2e9b2 100644 (file)
@@ -33,22 +33,19 @@ class Base extends Command {
                                'output',
                                null,
                                InputOption::VALUE_OPTIONAL,
-                               'Output format (plain, print or json, default is plain)',
+                               'Output format (plain, json or json_pretty, default is plain)',
                                'plain'
                        )
                ;
        }
 
        protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items) {
-               $outputFormat = $input->getOption('output');
-               switch ($outputFormat) {
+               switch ($input->getOption('output')) {
                        case 'json':
-                       case 'print':
-                               if ($outputFormat === 'json') {
-                                       $output->writeln(json_encode($items));
-                               } else {
-                                       print_r($items);
-                               }
+                               $output->writeln(json_encode($items));
+                               break;
+                       case 'json_pretty':
+                               $output->writeln(json_encode($items, JSON_PRETTY_PRINT));
                                break;
                        default:
                                foreach ($items as $key => $item) {