5 * Contains \Drush\Psysh\Shell.
10 use Psy\Shell as BaseShell;
11 use Symfony\Component\Console\Input\StringInput;
13 class Shell extends BaseShell {
16 * Get a command (if one exists) for the current input string.
18 * @param string $input
20 * @return null|Command
22 protected function getCommand($input) {
23 if ($name = $this->getCommandFromInput($input)) {
24 return $this->get($name);
29 * Check whether a command is set for the current input string.
31 * @param string $input
33 * @return bool True if the shell has a command for the given input.
35 protected function hasCommand($input) {
36 if ($name = $this->getCommandFromInput($input)) {
37 return $this->has($name);
44 * Get the command from the current input, takes aliases into account.
46 * @param string $input
50 * The current command.
52 protected function getCommandFromInput($input) {
53 // Remove the alias from the start of the string before parsing and
54 // returning the command. Essentially, when choosing a command, we're
55 // ignoring the site alias.
56 $input = preg_replace('|^\@[^\s]+|', '', $input);
58 $input = new StringInput($input);
59 return $input->getFirstArgument();