@param string $commandClass
@param array $args

@return AbstractCommand
488608
public function switchTo($commandClass, array $args = [])
    {
        $cmd = new $commandClass($args);
        $cmd->input = $this->input;
        $cmd->storage = $this->storage;
        $cmd->logs = $this->logs;
        $this->switchTo = $cmd;

        return $cmd;
    }
573324
protected function execute(CommandInterface $command, array $arguments)
	{
		return $this->container->call([$command, 'execute'], $this->convertArgumentsToCamelCase($arguments));
	}
180341
protected static function createFacade($class='', $args=[])
    {
        $class=$class ?: static::class;
        $facadeClass=static::getFacadeClass();
        if ($facadeClass) {
            $class=$facadeClass;
        } elseif (isset(self::$bind[$class])) {
            $class=self::$bind[$class];
        }
        return Container::getInstance()->make($class, $args);
    }
668861
public function execute(array $args = [], array $options = [])
    {
        foreach ($this->sequence as $command) {
            $command->setConfig($this->getConfig());
            $command->setConfigService($this->getConfigService());
            if ($this->hasOutput() && method_exists($command, 'setOutput')) {
                $command->setOutput($this->getOutput());
            }
            if ($this->hasInput() && method_exists($command, 'setInput')) {
                $command->setInput($this->getInput());
            }
            $command->execute($args, $options);
        }
    }
624737
public function newInstance(string $class, $args = [], string $selector = Injector::DEFAULT_SELECTOR)
    {
        if (!class_exists($class))
            throw new DIException("Class $class does not exist");

        if (isset($this->factories[$class]))
            return $this->factories[$class]->produce($class, $args, $selector, $this);

        return $this->default_factory->produce($class, $args, $selector, $this);
    }
455340
public static function executeCommand(string $class, ConsoleOutput $output, array $inputs) : int
    {
        if (!class_exists($class)) {
            throw new \RuntimeException((sprintf("Undefined class '%s'", $class)));
        }

        $command = new $class();

        if (!$command instanceof Command) {
            throw new \RuntimeException(sprintf("Invalid class '%s'", $class));
        }

        $input = new ArrayInput($inputs, $command->getDefinition());

        $command
            ->setInput($input)
            ->setOutput($output)
            ->setStart();

        return $command->execute($input, $output);
    }
2522
public function exec($cmd, $args = array())
    {
        // Arguments must be safe
        if (!is_array($args)) {
            $args = array($args);
        }
        foreach ($args as $val) {
            if (!is_string($val)) {
                throw new BaseException('You must specify arguments as strings');
            }
            $this->args[] = escapeshellarg($val);
        }

        // Command myst be safe
        $this->cmd = escapeshellcmd($cmd);

        $this->debug('Executing '.$cmd.($this->args ? ' '.implode(' ', $this->args) : ''));
        // Now do the execution
        $this->executeRaw($this->cmd.' '.implode(' ', $this->args));

        return $this;
    }
1244780
protected function execCommand(string $cmd, ...$args)
    {
        $command = $this->predis->createCommand($cmd, $args);
        $response = $this->predis->executeCommand($command);

        if ($response instanceof ErrorInterface) {
            return false;
        }

        if ($response instanceof Status) {
            return $response->getPayload() === 'OK';
        }

        return $response;
    }
475278
final public static function exec(string $cmd, array $args=[]) {
		foreach ($args as $key => $val)
			$args[$key] = escapeshellarg($val);
		$cmd = vsprintf($cmd, $args);
		exec($cmd, $output, $retcode);
		if ($retcode !== 0)
			return false;
		return $output;
	}
1296559
private function cmdMount($args)
    {
        $cmd = new MountCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
194663
public function createCache($class, $args)
    {
        /** @var CacheInterface $cache */
        $reflection = new ReflectionClass($class);
        $cache = $reflection->newInstanceArgs($args);

        // Assign cache logger
        if ($this->logger && $cache instanceof LoggerAwareInterface) {
            $cache->setLogger($this->logger);
        }

        return $cache;
    }
772191
public static function constructClassInstance( $clazz, $args ) {
		// $args should be a non-associative array; show nice error if that's not the case
		if ( $args && array_keys( $args ) !== range( 0, count( $args ) - 1 ) ) {
			throw new InvalidArgumentException( __METHOD__ . ': $args cannot be an associative array' );
		}

		return new $clazz( ...$args );
	}
679908
private function cmdClone($args)
    {
        $cmd = new CloneCommand($this->cwd);

        return $cmd->run(array_slice($args, 1));
    }
881093
public function add(array $updates, $class, $append = true)
    {
        $commandClass = $this->getCommandClass('update.add');
        $this->command = new $commandClass($updates, $class, $append);

        return $this->command;
    }
64772
public static function findCommandLong($arg) {
		foreach (self::$commands as $command => $commandOptions) {
			if (($commandOptions["commandLong"] == $arg) || ($commandOptions["commandShort"] == $arg)) {
				return $command;
			}
		}
		return false;
	}
1008842
private function getArgs(array $args, $cmd, $response, $driverId)
    {
        $response = array($response);
        $allowedArgs = $this->commands[$cmd];
        unset($allowedArgs['interface']);
        foreach ($allowedArgs as $key => $value) {
            if (isset($args[$key])) {
                $response[$key] = $args[$key];
                if (isset($this->filenameInRequest[$key])) {
                    $response[$key] = self::getNameByTarget($args[$key], $driverId);
                } elseif ($key == 'targets') {
                    $response[$key] = array_map(
                        function ($val) use ($driverId) {
                            return self::getNameByTarget($val, $driverId);
                        },
                        $args[$key]
                    );
                }
            } elseif (isset($this->defaultValues[$key])) {
                $response[$key] = $this->defaultValues[$key];
            } elseif ($value) {
                $this->error(sprintf('parameter "%s" in cmd "%s" required', $key, $cmd));
            }
        }

        return $response;
    }
760432
public function run($args)
	{
		$runner=$this->getCommandRunner();
		$commands=$runner->commands;
		if(isset($args[0]))
			$name=strtolower($args[0]);
		if(!isset($args[0]) || !isset($commands[$name]))
		{
			echo <<<EOD
At the prompt, you may enter a PHP statement or one of the following commands:

EOD;
			$commandNames=array_keys($commands);
			sort($commandNames);
			echo ' - '.implode("\n - ",$commandNames);
			echo <<<EOD


Type 'help <command-name>' for details about a command.

To expand the above command list, place your command class files
under 'protected/commands/shell', or a directory specified
by the 'YIIC_SHELL_COMMAND_PATH' environment variable. The command class
must extend from CConsoleCommand.

EOD;
		}
		else
			echo $runner->createCommand($name)->getHelp();
		return 1;
	}