Compose a process with given command. If no process is given in current instance a new one will be created.

@param string $command

@return Process

@since 2.0
15286
private function composeProcess(string $command): Process
    {
        if ($this->process === null) {
            $this->process = new Process([$command]);
        }

        $this->process->inheritEnvironmentVariables();
        $this->process->setTimeout($this->timeout);
        $this->process->setCommandLine($command);

        return $this->process;
    }
1242469
protected function composerRunCommand($command)
    {
        $this->info("Run \"$command\".");

        $output = [];
        exec($command, $output, $returnStatusCode);

        if ($returnStatusCode !== 0) {
            throw RuntimeException::commandExecutionFailed($command, $returnStatusCode);
        }

        $this->info("\"$command\" was successfully ran.");
    }
1262197
public function add(\Strukt\Console\Command $command){

		$class = get_class($command);
		$docBlockParser = new \Strukt\Console\DocBlockParser($class);
		$docList = $docBlockParser->parse();

		$cmdAlias = $docList["command"]["alias"];
		$this->commands[$cmdAlias]["object"] = $command;
		$this->commands[$cmdAlias]["docparser"] = $docBlockParser;
		$this->commands[$cmdAlias]["doclist"] = $docList;

		if($this->padlen == 0 || strlen($docList["command"]["alias"]) > $this->padlen)
			$this->padlen = strlen($docList["command"]["alias"]);
	}
1017823
public function getProcessByCommand(string $command) : Process {
        if( ! array_key_exists($command, $this->processes) ) {
            $this->watch($command);
        }

        foreach($this->getWatchedProcesses() as $process) {
            if($process->getCommand() === $command) {
                return $process;
            }
        }
    }
683884
public function drush($command) {
    // @todo Set to silent if verbosity is less than very verbose.
    $bin = $this->getConfigValue('composer.bin');
    /** @var \Robo\Common\ProcessExecutor $process_executor */
    $drush_alias = $this->getConfigValue('drush.alias');
    $command_string = "'$bin/drush' @$drush_alias $command";

    // URIs do not work on remote drush aliases in Drush 9. Instead, it is
    // expected that the alias define the uri in its configuration.
    if ($drush_alias != 'self') {
      $command_string .= ' --uri=' . $this->getConfigValue('site');
    }

    $process_executor = Robo::process(new Process($command_string));

    return $process_executor->dir($this->getConfigValue('docroot'))
      ->interactive(FALSE)
      ->printOutput(TRUE)
      ->printMetadata(TRUE)
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERY_VERBOSE);
  }
611624
public function run(string $command) : Process {
        $mutedCommand = Str::startsWith($command, 'artisan')
            ? str_replace('artisan ', '', $command)
            : $command;

        ignore_user_abort();

        $logName    = explode(' -', $mutedCommand, 2)[0];
        $log        = storage_path('logs' . DIRECTORY_SEPARATOR . snake_case(Str::slug($logName)) . '.log');
        $rootPath   = base_path();

        shell_exec("cd $rootPath && php artisan $mutedCommand >> " . $log . " &");

        exec('pgrep php', $processIds);
        exec('ps ahxwwo pid:1,command:1 | grep php | grep -v grep | grep -v emacs', $processes);

        $this->check();

        return $this->getProcessByCommand($command);
    }
14766
public function execute(string $command) : array
    {
        $this->result = [];
        $process = new Process(
            $this->propelCommand . ' ' . $command . ' --config-dir=' . $this->configDir,
            $this->rootDirectory
        );

        $process->run([$this, 'handle']);

        return $this->result;
    }
344
public function add($command)
    {
        $tasks = $this->prepper
                    ->load(get_class($command))
                    ->describe();

        $this->library->add(['task' => $tasks, 'class' => $command]);

        return $this;
    }
1164630
public function executeProcess($command)
    {
        $process = new Process($command);
        $process->setTimeout(null);
        $output = $this->output;
        $callback = function ($type, $data) use ($output) {
            $output->writeln(trim($data));
        };
        $exitCode = $process->run($callback);
        return [$exitCode, trim($process->getOutput())];
    }
1295064
public function command($command)
    {
        if (! $command instanceof Command) {
            $command = $this[$command];
        }

        $this['console']->add($command);
    }
1110866
protected function attachComposerFactory(BaseCommand $command)
    {
        if (!method_exists($command, 'setComposerFactory')) {
            throw new \InvalidArgumentException('The passed command does not implement method setComposerFactory()');
        }

        /** @var WrappedCommandTrait $command */
        $command->setComposerFactory(
            function () {
                return Factory::create($this->getIO());
            }
        );

        return $command;
    }
1082630
protected function runCommand($command)
    {
        $process = new Process($command);

        $process->run();

        if ( ! $process->isSuccessful()) {
            throw new \RuntimeException($process->getErrorOutput());
        }

        return $process->getExitCode();
    }
1199305
protected function registerMakeRuleCommand($command)
     {
         $this->app->singleton($command, function ($app) {
             return new Generators\Commands\RuleMakeCommand($app);
         });
     }
1293239
public function setCommand($command)
    {
        if (!preg_match(self::$_regex['command'], $command)) {
            throw new \InvalidArgumentException(sprintf('Command "%s" is incorect', $command));
        }

        $this->command = $command;

        return $this->generateHash();
    }
1262293
public function execute($command)
    {
        $validator = $this->translator->toValidator($command);

        if (class_exists($validator)) {
            $this->app->make($validator)->validate($command);
        }

        return $this->bus->execute($command);
    }
184355
public function command($command, array $parameters = [])
    {
        if (class_exists($command)) {
            $command = (new $command)->getName();
        }

        return $this->exec(
            Application::formatCommandString($command), $parameters
        );
    }
651131
public function resolveHandler($command)
    {
        if ($command instanceof SelfHandling) {
            return $command;
        }

        return $this->container->make($this->getHandlerClass($command));
    }