/** * @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; }