|
|
|
@ -27,7 +27,11 @@ use Symfony\Component\Console\Input\InputOption; |
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
|
|
|
|
|
class Base extends Command { |
|
|
|
|
protected $defaultOutputFormat = 'plain'; |
|
|
|
|
const OUTPUT_FORMAT_PLAIN = 'plain'; |
|
|
|
|
const OUTPUT_FORMAT_JSON = 'json'; |
|
|
|
|
const OUTPUT_FORMAT_JSON_PRETTY = 'json_pretty'; |
|
|
|
|
|
|
|
|
|
protected $defaultOutputFormat = self::OUTPUT_FORMAT_PLAIN; |
|
|
|
|
|
|
|
|
|
protected function configure() { |
|
|
|
|
$this |
|
|
|
@ -49,10 +53,10 @@ class Base extends Command { |
|
|
|
|
*/ |
|
|
|
|
protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items, $prefix = ' - ') { |
|
|
|
|
switch ($input->getOption('output')) { |
|
|
|
|
case 'json': |
|
|
|
|
case self::OUTPUT_FORMAT_JSON: |
|
|
|
|
$output->writeln(json_encode($items)); |
|
|
|
|
break; |
|
|
|
|
case 'json_pretty': |
|
|
|
|
case self::OUTPUT_FORMAT_JSON_PRETTY: |
|
|
|
|
$output->writeln(json_encode($items, JSON_PRETTY_PRINT)); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
@ -89,10 +93,10 @@ class Base extends Command { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch ($input->getOption('output')) { |
|
|
|
|
case 'json': |
|
|
|
|
case self::OUTPUT_FORMAT_JSON: |
|
|
|
|
$output->writeln(json_encode($item)); |
|
|
|
|
break; |
|
|
|
|
case 'json_pretty': |
|
|
|
|
case self::OUTPUT_FORMAT_JSON_PRETTY: |
|
|
|
|
$output->writeln(json_encode($item, JSON_PRETTY_PRINT)); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|