/** * Show a list of available options */ protected function showOptions() { $this->writeln("Options:", Colors::YELLOW); $rows = array(array(Colors::colorize('--version', Colors::GREEN), "Show version number"), array(Colors::colorize('--working-dir=DIR', Colors::GREEN), "If specified, use the given directory as working directory"), array(Colors::colorize('--config=FILE', Colors::GREEN), "Use an alternative config file")); $formater = new TextFormater(array('indent' => 2)); $table = new Table(null, $rows, array('border' => false, 'frame' => false)); $this->writeln($formater->format($table->render())); }
/** * Show available options and commands */ protected function showCommands() { $formater = new TextFormater(array('indent' => 2)); $this->writeln('Available commands:', Colors::YELLOW); $rows = []; foreach ($this->console->getCommands() as $name => $fqdn) { $help = Help::fromFQDN($fqdn); $rows[] = array(Colors::colorize($name, Colors::GREEN), $help->getShortDescription()); } $table = new Widgets\Table(null, $rows, array('border' => false, 'frame' => false)); $this->writeln($formater->format($table->render())); }
public function execute(array $args, array $options = array()) { if (empty($args)) { $formater = new ConsoleKit\TextFormater(array('quote' => ' * ')); $this->writeln('Available commands:', ConsoleKit\Colors::BLACK | ConsoleKit\Colors::BOLD); foreach ($this->console->getCommands() as $name => $fqdn) { if ($fqdn !== __CLASS__) { $this->writeln($formater->format($name)); } } $this->writeln("Use 'clamp help command' for more info"); } else { $commandFQDN = $this->console->getCommand($args[0]); $help = ConsoleKit\Help::fromFQDN($commandFQDN, ConsoleKit\Utils::get($args, 1)); $this->writeln($help); } }
/** * Show a lists with all updates and their status */ public function showComplete() { $updates = $this->dbvc()->getUpdatesAvailable(); if (empty($updates)) { if ($this->verbosity) { $this->writeln("No updates available"); } return; } $done = $this->dbvc()->getUpdatesDone(); $prefix = ""; if ($this->verbosity) { $this->writeln("Available updates:", Colors::YELLOW); } if ($this->short) { $prefix = $this->verbosity ? " " : ''; foreach ($updates as $update) { $status = !in_array($update, $done) ? 'o' : 'x'; $this->writeln($prefix . $status . ' ' . $update); } } else { $rows = array(); foreach ($updates as $update) { $status = !in_array($update, $done) ? Colors::colorize('open', Colors::YELLOW) : Colors::colorize('done', Colors::GREEN); $rows[] = array($update, $status); } $formater = new \ConsoleKit\TextFormater(array('indent' => $this->verbosity ? 2 : 0)); $table = new Table(null, $rows, array('border' => false, 'frame' => false)); $this->writeln($formater->format($table->render())); } }
/** * Formats text using a {@see TextFormater} * * @param string $text * @param int|array $formatOptions Either an array of options for TextFormater or a color code * @return string */ public function format($text, $formatOptions = array()) { if (!is_array($formatOptions)) { $formatOptions = array('fgcolor' => $formatOptions); } $formatOptions = array_merge($this->defaultFormatOptions, $formatOptions); $formater = new TextFormater($formatOptions); return $formater->format($text); }
/** * Render subcommands * * @return string */ protected function renderSubcommands() { if (empty($this->subCommands)) { return null; } $rows = array(); foreach ($this->subCommands as $name => $desc) { $rows[] = array(Colors::colorize($name, Colors::GREEN), $desc); } $table = new Widgets\Table(null, $rows, array('border' => false, 'frame' => false)); $formater = new TextFormater(array('indent' => 2)); return Colors::colorize("Sub commands:\n", Colors::YELLOW) . $formater->format($table->render()) . "\n"; }