1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Make bin/diviner generate with no arguments mean "generate everything"

Summary: Ref T988. This makes it easier to generate documentation.

Test Plan: Ran with and without `--book`. Examined CLI output.

Reviewers: chad, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T988

Differential Revision: https://secure.phabricator.com/D8415
This commit is contained in:
epriestley 2014-03-05 13:00:50 -08:00
parent 873a4721b8
commit d07fc70bbe
3 changed files with 37 additions and 4 deletions

View file

@ -30,7 +30,7 @@ final class DivinerAtomizeWorkflow extends DivinerWorkflow {
} }
public function execute(PhutilArgumentParser $args) { public function execute(PhutilArgumentParser $args) {
$this->readBookConfiguration($args); $this->readBookConfiguration($args->getArg('book'));
$console = PhutilConsole::getConsole(); $console = PhutilConsole::getConsole();

View file

@ -38,7 +38,41 @@ final class DivinerGenerateWorkflow extends DivinerWorkflow {
} }
public function execute(PhutilArgumentParser $args) { public function execute(PhutilArgumentParser $args) {
$this->readBookConfiguration($args); $book = $args->getArg('book');
if ($book) {
$books = array($book);
} else {
$cwd = getcwd();
$this->log(pht('FINDING DOCUMENTATION BOOKS'));
$books = id(new FileFinder($cwd))
->withType('f')
->withSuffix('book')
->find();
if (!$books) {
throw new PhutilArgumentUsageException(
pht(
"There are no Diviner '.book' files anywhere beneath the ".
"current directory. Use '--book <book>' to specify a ".
"documentation book to generate."));
} else {
$this->log(pht('Found %s book(s).', new PhutilNumber(count($books))));
}
}
foreach ($books as $book) {
$short_name = basename($book);
$this->log(pht('Generating book "%s"...', $short_name));
$this->generateBook($book, $args);
$this->log(pht('Completed generation of "%s".', $short_name)."\n");
}
}
private function generateBook($book, PhutilArgumentParser $args) {
$this->atomCache = null;
$this->readBookConfiguration($book);
if ($args->getArg('clean')) { if ($args->getArg('clean')) {
$this->log(pht('CLEARING CACHES')); $this->log(pht('CLEARING CACHES'));

View file

@ -17,8 +17,7 @@ abstract class DivinerWorkflow extends PhabricatorManagementWorkflow {
return $this->config; return $this->config;
} }
protected function readBookConfiguration(PhutilArgumentParser $args) { protected function readBookConfiguration($book_path) {
$book_path = $args->getArg('book');
if ($book_path === null) { if ($book_path === null) {
throw new PhutilArgumentUsageException( throw new PhutilArgumentUsageException(
"Specify a Diviner book configuration file with --book."); "Specify a Diviner book configuration file with --book.");