You are here

public function Application::get in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Application.php \Symfony\Component\Console\Application::get()

Returns a registered command by name or alias.

Parameters

string $name The command name or alias:

Return value

Command A Command object

Throws

\InvalidArgumentException When command name given does not exist

1 call to Application::get()
Application::find in vendor/symfony/console/Application.php
Finds a command by name or alias.

File

vendor/symfony/console/Application.php, line 384

Class

Application
An Application is the container for a collection of commands.

Namespace

Symfony\Component\Console

Code

public function get($name) {
  if (!isset($this->commands[$name])) {
    throw new \InvalidArgumentException(sprintf('The command "%s" does not exist.', $name));
  }
  $command = $this->commands[$name];
  if ($this->wantHelps) {
    $this->wantHelps = false;
    $helpCommand = $this
      ->get('help');
    $helpCommand
      ->setCommand($command);
    return $helpCommand;
  }
  return $command;
}