/** * @param ICommand $command */ public function render(ICommand $command) { $arguments = $command->getArguments(); if (count($arguments) === 0) { return; } $table = new TableWidget($this->input, $this->output); $table->setTitle("<header>Arguments:</header>"); foreach ($arguments as $argument) { $name = $argument->getName(); $description = $argument->getDescription(); if ($argument->isRequired()) { if ($argument->isMultiple()) { $name = "\\<{$name}...>"; } else { $name = "\\<{$name}>"; } } else { if ($argument->isMultiple()) { $name = "\\<{$name}... ?>"; } else { $name = "\\<{$name} ?>"; } } $table->addRow("<keyword>{$name}</keyword>", $description); } $this->output->writeLine(); $table->render(); }
/** * @param IConsole $console */ public function render(IConsole $console) { $facts = $this->gatherFacts($console->getCommands()); if (count($facts) > 0) { $table = new TableWidget($this->input, $this->output); $table->setTitle("<header>Available commands:</header>"); $headers = []; foreach ($facts as $name => $description) { if (stripos($name, ':') !== false) { $header = array_first(explode(':', $name)); if (!array_contains($headers, $header)) { $headers[] = $header; $table->addSection("<header>{$header}</header>"); } } $table->addRow("<keyword>{$name}</keyword>", $description); } $this->output->writeLine(); $table->render(); } else { $this->output->writeLineIndented('There are no commands yet'); } }
/** * @param ICommand $command */ public function render(ICommand $command) { $options = $command->getOptions(); if (count($options) === 0) { return; } $table = new TableWidget($this->input, $this->output); $table->setTitle("<header>Options:</header>"); foreach ($options as $option) { $name = $option->getName(); $alias = ' '; if ($option->getAlias()) { $alias = $option->getAlias(); if ($option->isIncremental()) { $alias = s('-:a|:a:a|:a:a:a', [':a' => substr($alias, 1)]); } $alias .= ','; } $table->addRow("<keyword>{$alias} {$name}</keyword>", $option->getDescription()); } $this->output->writeLine(); $table->render(); }
/** * @param array $facts */ private function renderFacts(array $facts) { $table = new TableWidget($this->input, $this->output); $section = ["Method", "Filter", "Route"]; foreach ($facts as $index => $fact) { if ($index === 0) { $table->addRow($section); } else { if ($index % 20 === 0) { $table->addRow(''); $table->addRow($section); } } $path = array_get($fact, 'path'); $methods = implode(', ', array_get($fact, 'methods')); $filters = implode(', ', array_get($fact, 'filters')); $table->addRow("<green>{$methods}</green>", "<yellow>{$filters}</yellow>", $path); } $table->render(); }