5 * Contains \Drush\Psysh\Shell.
10 use Psy\Shell as BaseShell;
11 use Symfony\Component\Console\Input\StringInput;
13 class Shell extends BaseShell
17 * Get a command (if one exists) for the current input string.
19 * @param string $input
23 protected function getCommand($input)
25 if ($name = $this->getCommandFromInput($input)) {
26 return $this->get($name);
31 * Check whether a command is set for the current input string.
33 * @param string $input
35 * @return bool True if the shell has a command for the given input.
37 protected function hasCommand($input)
39 if ($name = $this->getCommandFromInput($input)) {
40 return $this->has($name);
47 * Get the command from the current input, takes aliases into account.
49 * @param string $input
53 * The current command.
55 protected function getCommandFromInput($input)
57 // Remove the alias from the start of the string before parsing and
58 // returning the command. Essentially, when choosing a command, we're
59 // ignoring the site alias.
60 $input = preg_replace('|^\@[^\s]+|', '', $input);
62 $input = new StringInput($input);
63 return $input->getFirstArgument();