protected function DrushCommand::buildHelpFromConfig

8.0.x DrushCommand.php protected DrushCommand::buildHelpFromConfig()
master DrushCommand.php protected DrushCommand::buildHelpFromConfig()

Build a command help from the Drush configuration array.

Currently it's a word-wrapped description, plus any examples provided.

Return value

string The help string.

1 call to DrushCommand::buildHelpFromConfig()

File

lib/Drush/Psysh/DrushCommand.php, line 218
Contains \Drush\Psysh\DrushCommand.

Namespace

Drush\Psysh

Class

DrushCommand
Main Drush command.

Code

protected function buildHelpFromConfig() {
  $help = wordwrap($this->config['description']);

  $examples =[];
  foreach ($this->config['examples'] as $ex => $def) {
    // Skip empty examples and things with obvious pipes...
    if (($ex === '') || (strpos($ex, '|') !== FALSE)) {
      continue;
    }

    $ex = preg_replace('/^drush\s+/', '', $ex);
    $examples[$ex] = $def;
  }

  if (!empty($examples)) {
    $help .= "\n\ne.g.";

    foreach ($examples as $ex => $def) {
      $help .= sprintf("\n<return>// %s</return>\n", wordwrap(OutputFormatter::escape($def), 75, "</return>\n<return>// "));
      $help .= sprintf("<return>>>> %s</return>\n", OutputFormatter::escape($ex));
    }
  }

  return $help;
}