Run action of console command by name

@access public

@param string $name Command name

@return ResponseInterface
@throws \RuntimeException|\InvalidArgumentException|Exception
199059
public function action($name)
    {
        $command = '\\App\\Consoles\\'.ucfirst($name).'ConsoleCommand';
        $command = class_exists($command) ? $command : '\\Micro\\Cli\\Consoles\\'.ucfirst($name).'ConsoleCommand';

        if (!class_exists($command)) {
            throw new Exception('Command `'.$name.'` not found');
        }

        /** @var ConsoleCommand $command */
        $command = new $command();
        $command->execute();

        $response = (new ResponseInjector)->build();
        $response = $response->withHeader('status', (string)(int)$command->result);

        $stream = $response->getBody();
        $stream->write($command->message);

        return $response->withBody($stream);
    }
658738
public function run($name, array $input)
    {
        if (!isset($this->commands[$name])) {
            throw new CommandNotFoundException($name, $this->commands);
        }
        $this->commands[$name]->execute($input);
    }
125172
private function configCommand(string $name) : Result
    {
        $cmd = (new Get($this->repo->getRoot()));
        $cmd->name($name);

        return $this->runner->run($cmd);
    }
749515
public function get($name)
    {
        $this->init();

        if (!$this->has($name)) {
            throw new CommandNotFoundException(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;
    }
1057703
public function execute($name, AnCommandContext $context)
    {
        $parts = explode('.', $name);

        if ($parts[0] == 'before') {
            $action = $parts[1];

            //Check if the action exists
            if (!in_array($action, $context->caller->getActions())) {
                throw new LibBaseControllerExceptionNotImplemented(
                        'Action '.ucfirst($action).' Not Implemented');
            }

            if ($this->_mixer->canExecute($action) === false) {
                if ($this->viewer && !$this->viewer->guest()) {
                    throw  new LibBaseControllerExceptionForbidden('Action '.ucfirst($action).' Not Allowed');
                } else {
                    throw  new LibBaseControllerExceptionUnauthorized('Action '.ucfirst($action).' Not Allowed');
                }
            }
        }

        return true;
    }
170600
public function create($name)
    {
        $config = $this->getConfiguration($name);

        if(null === $config) {
            throw new \RuntimeException(
                "Connection with name: $name not found."
            );
        }

        return new Client($config);
    }
377204
public static function build($name)
    {
        $class = '\\Ebanx\\Command\\';

        $className = str_replace('do', '', $name);

        if ($className == $name)
        {
            $className = str_replace('get', '', $name);
        }

        $class .= $className;

        // Request command is different depending on the checkout method (Ebanx or direct)
        if ($className == 'Request')
        {
            // Use EBANX direct
            if (\Ebanx\Config::getDirectMode() == true)
            {
                $class .= '\\Direct';
            }
            // Use EBANX checkout
            else
            {
                $class .= '\\Checkout';
            }
        }

        if (class_exists($class))
        {
            return new $class();
        }
        else
        {
            throw new \RuntimeException("Command '$className' doesn't exist.");
        }
    }
760060
public function fetchCommand($name)
    {
        $name = ucfirst($name);

        $file = null;
        $packageName = null;

        foreach ($this->defaultCommandsPaths as $package => $path) {
            $file_handler = new FileHandler($path);

            $file = $file_handler->getFile($name);
            if (false !== $file) {
                $packageName = $package;

                break;
            }
        }

        if (false === $file) {
            $this->error(
                sprintf(
                    'Unknown command: ` %1$s`. Does the file exists `%2$s/%1$s.php` ?'.PHP_EOL,
                    $name,
                    $this->defaultCommandsPaths
                )
            );
            $message = $this->ansiFormat(sprintf('php %s.php help', $this->managerName), Console::FG_YELLOW);
            $this->normal(sprintf('Type %s for usage.'.PHP_EOL, $message));
        }

        // commands are in the commands namespace
        /** @var $className BaseCommand */
        $className = ClassHelper::getFormatNamespace($packageName).'Console\Command\\'.$name;

        return new $className();
    }
457371
public function execute($name, array $params = [], array $headers = [])
    {
        $executor = new Executor($this);

        return $executor->run($name, $params, $headers);
    }
515269
public function execute($name, AnCommandContext $context)
    {
        $parts = explode('.', $name);

        if ($parts[0] == 'before') {
            $value = pick($this->{$this->getIdentifiableKey()}, $context->data->{$this->getIdentifiableKey()});

            if ($value) {
                $parent = $this->getParentRepository()->fetch($value);

                $this->setParent($parent);

                //set the entity owner as the context actor of the controller
                if ($parent && $this->getRepository()->isOwnable() && $this->isOwnable()) {
                    $this->setActor($parent->owner);
                }

                $context->data['parent'] = $parent;
            }
        }
    }
300909
protected function executeSubCommand($name, IOInterface $io = null)
    {
        if (empty($this->children[$name])) {
            throw new CommandNotFoundException(sprintf('Command "%s" not found.', $name), $this, $name);
        }

        /** @var $subCommand AbstractCommand */
        $subCommand = $this->children[$name];

        // Remove first argument and send it to child
        if (!$io) {
            $io = $this->io;

            $io->shiftArgument();
        }

        $subCommand->setIO($io)
            ->setApplication($this->console);

        return $subCommand->execute();
    }
116464
public function runCommand($commandName, array $args = [])
    {
        $application = $this->getApplication();

        $command = $application->find($commandName);

        $arrayInput = new ArrayInput($args);

        $arrayInput->setInteractive(false);

        $command->run($arrayInput, $this->getOutput());
    }
795186
public function register($name)
	{
		return $this->addCommand(new Command($name, $this->input, $this->output));
	}
836749
protected function runInput($name, array $options, $default = null)
    {
        return $this->command->ask($this->generatePrompt($name, $options['prompt']), $default);
    }
319055
public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        $this->setAutoExit(false);
        $this->getContainer()->boot();
        $this->setDispatcher($this->getContainer()['dispatcher']);
        $this->getContainer()['dispatcher']->dispatch(ConsoleEvents::INIT, new ConsoleEvent($this));
        $this->getContainer()->flush();
        $exitCode = parent::run($input, $output);
        $this->getContainer()->terminate(new Request(), new Response());

        return $exitCode;
    }
114278
public function run($name, AnCommandContext $context)
    {
        if ($this->_enabled) {
            $this->getStack()->push(clone $this);

            foreach ($this->getStack()->top() as $command) {
                if ($command->execute($name, $context) === $this->_break_condition) {
                    $this->getStack()->pop();
                    return $this->_break_condition;
                }
            }

            $this->getStack()->pop();
        }
    }
108566
public static function validateCommandName($name)
    {
        $name = trim($name);

        if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
            throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
        }

        return $name;
    }