Skip to content

Commit 60e9ee0

Browse files
Merge pull request #108 from peterjaap/patch-1
Add JSON output format flag and correct return value in ListCommand
2 parents 6d8e2de + c89616a commit 60e9ee0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Composer/Commands/ListCommand.php

Lines changed: 14 additions & 1 deletion
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,7 +200,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
193200
));
194201
}
195202

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

199212
private function createUnfilteredPatchLoaderPool(\Vaimo\ComposerPatches\Composer\Context $composerContext)

0 commit comments

Comments
 (0)