Skip to content

Commit c89616a

Browse files
authored
Add json output format flag
1 parent caada4e commit c89616a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Composer/Commands/ListCommand.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ protected function configure()
9696
InputOption::VALUE_NONE,
9797
'Use latest information from package configurations in vendor folder'
9898
);
99+
100+
$this->addOption(
101+
'--json',
102+
null,
103+
InputOption::VALUE_NONE,
104+
'Output the list of patches in JSON format'
105+
);
99106
}
100107

101108
protected function execute(InputInterface $input, OutputInterface $output)
@@ -193,8 +200,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
193200
));
194201
}
195202

196-
$this->generateOutput($output, $patches);
197-
203+
if ($input->getOption('json')) {
204+
$output->writeln(json_encode($patches));
205+
} else {
206+
$this->generateOutput($output, $patches);
207+
}
208+
198209
return self::SUCCESS;
199210
}
200211

0 commit comments

Comments
 (0)