Renders a command as a link tag. If it has a href, it will use the route to Route the link.

@param ComBaseControllerToolbarCommand $command Command to render as a link

@return string
335270
public function command($command)
    {
        $attributes = AnConfig::unbox($command->getAttributes());

        if (isset($attributes['icon'])) {
            $icon = 'icon-'.$attributes['icon'];
            $command->label = '<i class="'.$icon.'"></i>&nbsp;'.$command->label;
            unset($attributes['icon']);
        }

        $html = $this->getService('com:base.template.helper.html');

        return (string) $html->tag('a', $command->label, $attributes);
    }
977988
public static function routeCommand($command = 'help')
	{
		// Aliases take precedence, so parse for them first
		if ($aliases = Config::get('aliases'))
		{
			if (array_key_exists($command, $aliases))
			{
				if (strpos($aliases->$command, '::') !== false)
				{
					$bits      = explode('::', $aliases->$command);
					$command   = $bits[0];
					$aliasTask = $bits[1];
				}
				else
				{
					$command = $aliases->$command;
				}
			}
		}

		foreach (self::$commandNamespaces as $namespace)
		{
			// Check if we're targeting a namespaced command
			$bits = [];
			if (strpos($command, ':'))
			{
				$bits = explode(':', $command);
			}
			else
			{
				$bits[] = $command;
			}

			$bits = array_map('ucfirst', $bits);

			// Replace any inset placeholders
			for ($i = 0; $i < count($bits); $i++)
			{
				$loc = $i + 1;
				if (strpos($namespace, "{\$$loc}"))
				{
					$namespace = str_replace("{\$$loc}", $bits[$i], $namespace);
					unset($bits[$i]);
				}
			}

			// Add any remaining bits to the end of the command namespace
			if (count($bits) > 0)
			{
				$namespace .= '\\' . implode('\\', $bits);
			}

			// Check for existence
			if (class_exists($namespace))
			{
				$class = $namespace;
				break;
			}
		}

		if (!isset($class))
		{
			throw new UnsupportedCommandException("Unknown command: {$command}.");
		}

		return $class;
	}
852481
public static function getCommand($command)
    {
        if (!is_string($command) || strlen($command) < 1) {
            throw new BadMethodCallException('Parameter command is not a valid string');
        }
        $instance = self::getInstance();
        
        if (!isset($instance->commands[$command])) {
            throw new BadMethodCallException('Command "' . $command . '" is not a registered command');
        }
        
        return $instance->commands[$command];
    }
493456
private function runRouteCommand($command, $params = null)
    {
        $this->routerCommand()->runRoute(
            $command,
            $params,
            $this->baseFolder . '/' . $this->paths['controllers'],
            $this->namespaces['controllers']
        );
    }
81631
protected function doAction(Command $command)
    {
        if ($command->name() === '__default__') {
            return $this->notFound();
        }

        // Let the command collect more data (if missing or needs confirmation)
        $command->interact($this->io());

        if (!$command->action() && !\method_exists($command, 'execute')) {
            return;
        }

        $params = [];
        $values = $command->values();
        // We prioritize action to be in line with commander.js!
        $action = $command->action() ?? [$command, 'execute'];

        foreach ($this->getActionParameters($action) as $param) {
            $params[] = $values[$param->getName()] ?? null;
        }

        return $action(...$params);
    }
639642
public function build($command)
    {
        return sprintf(
            '%s %s/%s %s --env=%s --no-debug',
            PhpUtils::getPhp(),
            $this->consoleDir,
            'console',
            $command,
            $this->environment
        );
    }
54513
protected function _commandDelete($command)
    {
        $entity = $this->getController()->getItem();

        $name = AnInflector::pluralize($this->getController()->getIdentifier()->name);
        $redirect = 'option=com_'.$this->getIdentifier()->package.'&view='.$name;

        $command->append(array('label' => AnTranslator::_('LIB-AN-ACTION-DELETE')))
        ->href(route($entity->getURL()))
        ->setAttribute('data-action', 'delete')
        ->setAttribute('data-redirect', route($redirect))
        ->class('action-delete');
    }
1209845
public function addCommand(Command $command)
    {
        if (is_string($command)) {
            $command = new $command;
        }
        $map = (new CommandMapping($this->parser))->map($command);

        CommandBag::add($map->name, [
            'object' => $command,
            'map' => $map
        ]);

        return $this;
    }
1168998
private function phpCommand($command, $params = [])
    {
        return implode(' ', array_merge([ PHP_BINARY, realpath($this->scriptRoot . DIRECTORY_SEPARATOR . $command) ], $params));
    }
631644
protected function call($command, $parameters = array())
    {
        if (!$this->send($command, $parameters)) {
            return false;
        }

        return $this->receive($this->tag);
    }
450720
protected function displayCommandHelp(string $command): int
	{
		$commandInstance = $this->instantiateCommandWithoutConstructor($this->commands[$command]);

		$this->output->writeLn('<yellow>Command:</yellow>');

		$this->output->write(PHP_EOL);

		$this->output->writeLn('php reactor ' . $command);

		$this->output->write(PHP_EOL);

		$this->output->writeLn('<yellow>Description:</yellow>');

		$this->output->write(PHP_EOL);

		$this->output->writeLn($commandInstance->getCommandDescription());

		if(!empty($arguments = $commandInstance->getCommandArguments()))
		{
			$this->drawTable('Arguments:', ['Name', 'Description', 'Optional'], $this->convertArgumentsAndOptionsArrayToRows($arguments));
		}

		if(!empty($options = $commandInstance->getCommandOptions()))
		{
			$this->drawTable('Options:', ['Name', 'Description', 'Optional'], $this->convertArgumentsAndOptionsArrayToRows($options));
		}

		return CommandInterface::STATUS_SUCCESS;
	}
258776
private function executeCommand($command)
    {
        $stdoutPath = tempnam(sys_get_temp_dir(), 'php-msMsgfOut');
        $stderrPath = tempnam(sys_get_temp_dir(), 'php-msMsGfErr');
        
        $descriptors = array(
            0 => array(
                'pipe',
                'r'
            ),
            1 => array(
                'file',
                $stdoutPath,
                'a'
            ),
            2 => array(
                'file',
                $stderrPath,
                'a'
            )
        );
        
        $process = proc_open($command, $descriptors, $pipes);
        proc_close($process);
        
        if (filesize($stderrPath) > 0) {
            throw new \InvalidArgumentException(file_get_contents($stderrPath));
        }
        
        return $stdoutPath;
    }
992472
public function aExecuteCommandTo($command) {
        $this->restartKernel();
        $kernel = $this->getKernel();

        $application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
        $application->setAutoExit(false);

        $exploded = explode(" ", $command);

        $commandsParams = [
        ];
        foreach ($exploded as $value) {
            if (!isset($commandsParams["command"])) {
                $commandsParams["command"] = $value;
            } else {
                $e2 = explode("=", $value);
//                var_dump($e2);
                if (count($e2) == 1) {
                    $commandsParams[] = $e2[0];
                } else if (count($e2) == 2) {
                    $commandsParams[$e2[0]] = $e2[1];
                }
            }
        }
        foreach ($commandsParams as $key => $value) {
            $commandsParams[$key] = $value;
        }
        $input = new \Symfony\Component\Console\Input\ArrayInput($commandsParams);
        if ($output === null) {
            $output = new \Symfony\Component\Console\Output\ConsoleOutput();
        }
        $application->run($input, $output);
//         $content = $output->fetch();
    }
402080
protected function renderCommand(BlockLayout $layout, Command $command)
    {
        $description = $command->getConfig()->getDescription();
        $name = '<c1>'.$command->getName().'</c1>';

        $layout->add(new LabeledParagraph($name, $description));
    }
381798
public function execute($command)
    {
        $this->executeDecorators($command);

        $handler = $this->commandTranslator->toCommandHandler($command);

        return $this->app->make($handler)->handle($command);
    }
445981
protected function renderItem($command)
    {
        if (!($command instanceof AbstractCommand)) {
            throw new \InvalidArgumentException('Command descriptor need Command object to describe it.');
        }

        /** @var Command $command */
        $name = $command->getName();
        $description = $command->getDescription() ?: 'No description';

        $template = str_replace('{WIDTH}', $this->maxLength + $this->offsetAfterCommand, $this->template);

        // Sets the body indent.
        $body = [];

        $description = explode("\n", $description);

        $line1 = array_shift($description);
        $body[] = sprintf($template, $name, $line1);

        foreach ($description as $line) {
            $line = trim($line);
            $line = sprintf($template, '', $line);
            $body[] = $line;
        }

        return implode("\n", $body);
    }
266051
private function formatCommand($command, $parameters)
    {
        $parameters = collect($parameters)->map(function ($parameter) {
            if (is_array($parameter)) {
                return collect($parameter)->map(function ($value, $key) {
                    return is_int($key) ? $value : "{$key} {$value}";
                })->implode(' ');
            }

            return $parameter;
        })->implode(' ');

        return "{$command} {$parameters}";
    }