Skip to content

Commit 3aa767a

Browse files
committed
Opting into JSON
1 parent 53fab97 commit 3aa767a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/Command/BuildDocsCommand.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ protected function configure()
5252
'Parse only given sub directory and combine it into a single file (directory relative from source-dir)',
5353
''
5454
)
55+
->addOption(
56+
'output-json',
57+
null,
58+
InputOption::VALUE_NONE,
59+
'If provided, .fjson metadata files will be written'
60+
)
5561
->addOption(
5662
'disable-cache',
5763
null,
@@ -69,6 +75,11 @@ protected function configure()
6975

7076
protected function initialize(InputInterface $input, OutputInterface $output)
7177
{
78+
if ($input->getOption('parse-sub-path') && $input->getOption('output-json')) {
79+
throw new \InvalidArgumentException(sprintf('Cannot pass both --parse-sub-path and --output-json options.'));
80+
}
81+
82+
7283
$sourceDir = $this->initializeSourceDir($input, $this->filesystem);
7384
$outputDir = $input->getArgument('output-dir') ?? $sourceDir.'/html';
7485

@@ -103,10 +114,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
103114
}
104115

105116
$metas = $this->getMetas();
106-
if (!$this->buildContext->getParseSubPath()) {
107-
$this->generateJson($metas);
108-
} else {
117+
if ($this->buildContext->getParseSubPath()) {
109118
$this->renderDocForPDF($metas);
119+
} elseif ($input->getOption('--output-json')) {
120+
$this->generateJson($metas);
110121
}
111122

112123
$this->io->newLine(2);

0 commit comments

Comments
 (0)