Changeset View
Changeset View
Standalone View
Standalone View
src/parser/argument/workflow/PhutilHelpArgumentWorkflow.php
| <?php | <?php | ||||
| final class PhutilHelpArgumentWorkflow extends PhutilArgumentWorkflow { | final class PhutilHelpArgumentWorkflow extends PhutilArgumentWorkflow { | ||||
| private $workflow; | |||||
| public function setWorkflow($workflow) { | |||||
| $this->workflow = $workflow; | |||||
| return $this; | |||||
| } | |||||
| public function getWorkflow() { | |||||
| return $this->workflow; | |||||
| } | |||||
| protected function didConstruct() { | protected function didConstruct() { | ||||
| $this->setName('help'); | $this->setName('help'); | ||||
| $this->setExamples(<<<EOHELP | $this->setExamples(<<<EOHELP | ||||
| **help** [__command__] | **help** [__command__] | ||||
| EOHELP | EOHELP | ||||
| ); | ); | ||||
| $this->setSynopsis(<<<EOHELP | $this->setSynopsis(<<<EOHELP | ||||
| Show this help, or workflow help for __command__. | Show this help, or workflow help for __command__. | ||||
| Show All 11 Lines | EOHELP | ||||
| public function isExecutable() { | public function isExecutable() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function execute(PhutilArgumentParser $args) { | public function execute(PhutilArgumentParser $args) { | ||||
| $with = $args->getArg('help-with-what'); | $with = $args->getArg('help-with-what'); | ||||
| if (!$with) { | if (!$with) { | ||||
| // TODO: Update this to use a pager, too. | |||||
| $args->printHelpAndExit(); | $args->printHelpAndExit(); | ||||
| } else { | } else { | ||||
| $out = array(); | |||||
| foreach ($with as $thing) { | foreach ($with as $thing) { | ||||
| echo phutil_console_format( | $out[] = phutil_console_format( | ||||
| "**%s**\n\n", | "**%s**\n\n", | ||||
| pht('%s WORKFLOW', strtoupper($thing))); | pht('%s WORKFLOW', strtoupper($thing))); | ||||
| echo $args->renderWorkflowHelp($thing, $show_flags = true); | $out[] = $args->renderWorkflowHelp($thing, $show_flags = true); | ||||
| echo "\n"; | $out[] = "\n"; | ||||
| } | |||||
| $out = implode('', $out); | |||||
| $workflow = $this->getWorkflow(); | |||||
| if ($workflow) { | |||||
| $workflow->writeToPager($out); | |||||
| } else { | |||||
| echo $out; | |||||
| } | } | ||||
| exit(PhutilArgumentParser::PARSE_ERROR_CODE); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||