/** * @return string help docs */ public function getHelp() { $this->attachHelp(); if (empty($this->name) && isset($this->tokens[0])) { $this->name = $this->tokens[0]; } $color = new \Colors\Color(); $help = ''; $help .= $color(\Commando\Util\Terminal::header(' ' . $this->name))->white()->bg('green')->bold() . PHP_EOL; if (!empty($this->help)) { $help .= PHP_EOL . \Commando\Util\Terminal::wrap($this->help) . PHP_EOL; } $help .= PHP_EOL; $seen = array(); $keys = array_keys($this->options); natsort($keys); foreach ($keys as $key) { $option = $this->getOption($key); if (in_array($option, $seen)) { continue; } $help .= $option->getHelp() . PHP_EOL; $seen[] = $option; } return $help; }
/** * @return string */ public function getHelp() { $color = new \Colors\Color(); $help = ''; $isNamed = $this->type & self::TYPE_NAMED; if ($isNamed) { $help .= PHP_EOL . (mb_strlen($this->name, 'UTF-8') === 1 ? '-' : '--') . $this->name; if (!empty($this->aliases)) { foreach ($this->aliases as $alias) { $help .= (mb_strlen($alias, 'UTF-8') === 1 ? '/-' : '/--') . $alias; } } if (!$this->isBoolean()) { $help .= ' ' . $color->underline('<argument>'); } $help .= PHP_EOL; } else { $help .= (empty($this->title) ? "arg {$this->name}" : $this->title) . PHP_EOL; } // bold what has been displayed so far $help = $color->bold($help); $titleLine = ''; if ($isNamed && $this->title) { $titleLine .= $this->title . '.'; if ($this->isRequired()) { $titleLine .= ' '; } } if ($this->isRequired()) { $titleLine .= $color->red('Required.'); } if ($titleLine) { $titleLine .= ' '; } $description = $titleLine . $this->description; if (!empty($description)) { $descriptionArray = explode(PHP_EOL, trim($description)); foreach ($descriptionArray as $descriptionLine) { $help .= Terminal::wrap($descriptionLine, 5, 1) . PHP_EOL; } } return $help; }