Returns a slot for the given command used for clustering distribution or
NULL when this is not possible.

@param string $command Command name.
@param array  $args

@return int|null
195275
public function getSlot($command, $args): ?int
    {
        $id = \strtoupper($command);

        $slot = null;

        if (isset($this->commands[$id])) {
            $key = $this->commands[$id]($id, $args);

            if (null !== $key) {
                $slot = $this->getSlotByKey($key);
            }
        }

        return $slot;
    }
902500
public static function escapeArguments(array $arguments, $command = null)
    {
        $processedArguments = array();
        foreach ($arguments as $key => $value) {
            if (is_string($key) && substr($key, 0, 1) === '-') {
                if (is_array($value) === false) {
                    $value = array($value);
                }

                foreach ($value as $optionValue) {
                    if ($optionValue === null) {
                        $processedArguments[] = $key;
                    } elseif (is_string($optionValue)) {
                        $processedArguments[] = trim(sprintf('%s=%s', $key, $optionValue));
                    }
                }
            } elseif (is_scalar($value)) {
                $processedArguments[] = $value;
            }
        }

        if ($command !== null) {
            array_unshift($processedArguments, $command);
        }

        return implode(' ', array_map(array(__CLASS__, 'escapeArgument'), $processedArguments));
    }
116431
protected function getKeyFromBlockingListCommands(CommandInterface $command)
    {
        $arguments = $command->getArguments();

        if ($this->checkSameSlotForKeys(array_slice($arguments, 0, count($arguments) - 1))) {
            return $arguments[0];
        }
    }
235953
public function _appendClause($command, array $args = []){
		if (!empty($command)){
			$this->_segments[] = $command;
		}
		
		if (!empty($args)){
			$this->_segments[] = array_shift($args);
			
			foreach($args as $arg){
				if (is_array($arg)){
					foreach($arg as $subArg)
						$this->_bind[] = $subArg;
				} else {
					$this->_bind[] = $arg;
				}
			}
		}
		
		return $this;
	}
1167916
public function get($command) {
        return isset($this->_commands[$command]) ?
            $this->_commands[$command] :
            null;
    }
519830
public function findJob($command, array $args = [])
    {
        return $this->_em->createQuery('SELECT j FROM JMSJobQueueBundle:Job j WHERE j.command = :command AND j.args = :args')
            ->setParameter('command', $command)
            ->setParameter('args', $args, Type::JSON_ARRAY)
            ->setMaxResults(1)
            ->getOneOrNullResult();
    }
863258
public static function coalesce($args)
    {
        $args = func_get_args();
        foreach ($args as &$arg) {
            if (isset($arg) && !empty($arg)) {
                return $arg;
            }
        }

        return null;
    }
1344283
public function processArgs( ICommand &$command, $args )
    {
        $i = 0;

        $ops = array_slice( $args, 2 );

        while ( $i < count( $ops ) )
        {
            $o = $ops[ $i ];

            if ( Option::isShortCode( $o ) || Option::isLongCode( $o ) )
            {
                $option = Command::getOption( $command, $o );

                if ( $option->isRequired )
                {
                    $i++;

                    if ( !Util::validIndex( $i, $ops ) )
                    {
                        throw new CommandException( 'Missing argument for option: ' . $o );
                    }

                    Option::setRequiredValue( $option, $ops[ $i ] );
                }

                if ( $option->isOptional )
                {
                    $value = NULL;

                    if ( $option->type === Type::BOOLEAN )
                    {
                        $value = TRUE;
                    }
                    else
                    {
                        $i++;

                        $value = $ops[ $i ];
                    }

                    if ( Util::validIndex( $i, $ops ) )
                    {
                        Option::setOptionalValue( $option, $value );
                    }
                    else if ( is_bool( $value ) )
                    {
                        Option::setOptionalValue( $option, $value );
                    }
                }
            }

            $i++;
        }
    }
64772
public static function findCommandLong($arg) {
		foreach (self::$commands as $command => $commandOptions) {
			if (($commandOptions["commandLong"] == $arg) || ($commandOptions["commandShort"] == $arg)) {
				return $command;
			}
		}
		return false;
	}
800868
public function get($command)
    {
        $commands = $this->getHandlers();
        return empty($commands[$command]) ? array() : $commands[$command];
    }
528052
public function exists(string $command, array $arguments = []): bool
    {
        return $this->storage->contains(function ($value) use ($command, $arguments) {
            return $value['command'] === $command && $value['arguments'] === $arguments;
        });
    }
823001
protected function usage(array $args = [], $command = null)
    {
        array_unshift($args, $command ?: '[command]');

        $this->climate->usage($args);

        if (empty($this->commands) || $command) {
            if (!$command) {
                $this->climate->br()->out('No command available');
            }

            return self::EXIT_SUCCESS;
        }

        $this->climate->br()->out(
            sprintf('<yellow>%s</yellow>:', 'Available Commands')
        );

        $names = array_map(function ($item) {
            return strlen($item);
        }, array_keys($this->commands));

        foreach ($this->commands as $name => $cmd) {
            $spc = max($names) + 2 - strlen($name);
            $this->climate->tab()->out(
                sprintf('<green>%s</green>%s%s', $cmd->name(), str_repeat(' ', $spc), $cmd->description())
            );
        }

        return self::EXIT_SUCCESS;
    }
1264402
protected function dispatchCommand($command, array $argumentBag = [])
    {
        $result = false;

        switch ($command) {

            case self::COMMAND_START:
                $result = $this->start(
                    $argumentBag['interface'],
                    $argumentBag['port'],
                    $argumentBag['docroot'],
                    isset($argumentBag['router']) ? ' '.$argumentBag['router'] : ''
                );
                break;

            case self::COMMAND_STOP:
                $result = self::COMMAND_STOP;
                break;

            case self::COMMAND_RESTART:
                $result = self::COMMAND_RESTART;
                break;

            case self::COMMAND_STATUS:
                $result = self::COMMAND_STATUS;
                break;

            default:
                $command = null;
                break;
        }

        return $result;
    }
1168667
public function getJob($command, array $args = [])
    {
        if (null !== $job = $this->findJob($command, $args)) {
            return $job;
        }

        throw new \RuntimeException(sprintf('Found no job for command "%s" with args "%s".', $command, json_encode($args)));
    }
1300783
protected function getDescribedCommand($args)
	{
		$this->describedCommand = $command = $this->getParent();

		foreach ($args as $arg)
		{
			$command = $command->getChild($arg);

			if (!$command)
			{
				throw new CommandNotFoundException(sprintf('Command: "%s" not found.', implode(' ', $args)), $this->describedCommand, $arg);
			}

			// Set current to describedCommand that we can use it auto complete wrong args.
			$this->describedCommand = $command;
		}

		return $command;
	}
681231
public function call($command, array $params = [])
    {
        $params['command'] = $command;
        $this->lastOutput = new BufferedOutput();

        return $this->find($command)->run(new ArrayInput($params), $this->lastOutput);
    }
387792
public function callCommand(string $command, array $arguments = [])
    {
        $newCommand = $this->getApplication()->find($command);

        $arguments['command'] = $command;

        return $newCommand->run(new ArrayInput($arguments), $this->getOutput());
    }