Runs the command chain

@return \Tivie\Command\Result[]
@throws \Tivie\Command\Exception\Exception
@throws \Tivie\Command\Exception\InvalidArgumentException
973456
public function run()
    {
        //Bogus variable set. The original value is never used, but IDEs complain
        $result = new Result();
        $resultArray = array();
        $max = count($this->commands);

        for ($i = 0; $i < $max; ++$i) {
            $cmd = $this->commands[$i];

            if ($i === 0) {
                $resultArray[] = $result = $cmd->run();
                continue;
            }

            if (($cmd->_runMode === RUN_IF_PREVIOUS_SUCCEEDS && $result->getExitCode() !== 0) ||
                ($cmd->_runMode === RUN_IF_PREVIOUS_FAILS && $result->getExitCode() === 0)
            ) {
                continue;
            }

            if ($cmd->_pipe) {
                $stdOut = trim($result->getStdOut());

                $isXArg = false;
                foreach ($cmd as $argIdx => $arg) {
                    if ($arg instanceof Argument) {
                        if (stripos($arg->getKey(true), PIPE_PH) !== false) {
                            $key = str_replace(PIPE_PH, $stdOut, $arg->getKey(true));
                            $arg->setKey($key);
                        }

                        $values = $arg->getValues();
                        foreach ($values as $index => $val) {
                            if (stripos($val, PIPE_PH) !== false) {
                                $val = str_replace(PIPE_PH, $stdOut, $val);
                                $arg->replaceValue($index, $val);
                                $isXArg = true;
                            }
                        }
                    }
                }
                if (!$isXArg) {
                    $cmd->setStdIn($stdOut);
                }
            }

            $resultArray[] = $result = $cmd->run();
        }

        return $resultArray;
    }
31034
public function run()
    {
        $maxATime = time() - self::TTL;

        $files = Finder::create()
            ->in($this->storePath)
            ->depth(1)
            ->name(Runner::BOOTSTRAP_FILENAME)
            ->filter(function (SplFileInfo $d) use ($maxATime) {
                return $d->getATime() < $maxATime;
            })
        ;

        $directories = array();

        foreach ($files as $file) {
            $directories[] = dirname($file);
        }

        $this->filesystem->remove($directories);
    }
1158601
private function prepareCommands(): array
    {
        $batches = array_chunk($this->queue, $this->batchSize);
        $this->queue = [];

        $commands = [];
        foreach ($batches as $batch) {
            $requests = [];
            foreach ($batch as $item) {
                if (!isset($requests[$item['table']])) {
                    $requests[$item['table']] = ['Keys' => [], 'ConsistentRead' => $this->consistentRead];
                }
                $requests[$item['table']]['Keys'][] = $item['key'];
            }
            $commands[] = $this->client->getCommand('BatchGetItem', ['RequestItems' => $requests]);
        }

        return $commands;
    }
484551
public function run()
    {
        $console = $this->console;
        $this->app->instance('console', $console);

        $this->loadBootstrap();
        $this->initializeSystemTimezone();

        $input = new ArgvInput();
        if ($input->getFirstArgument() !== 'c5:update') {
            if ($this->app->isInstalled()) {
                $this->app->setupPackageAutoloaders();
                $this->app->setupPackages();
            }
        }

        // Handle legacy backwards compatibility
        if (method_exists($console, 'setupDefaultCommands')) {
            $console->setupDefaultCommands();
        }

        \Events::dispatch('on_before_console_run');

        $console->run($input);

        \Events::dispatch('on_after_console_run');
    }
787920
public function run()
    {

        try {
            // register shutdown handler
            register_shutdown_function(array(&$this, "shutdown"));

            // store the actual directory
            $actualDir = getcwd();

            // load the node data with the command information
            $executeNode = $this->jobNode->getExecute();

            // try to load the script from the configuration
            if ($script = $executeNode->getScript()) {
                // change the working directory
                if ($execDir = $executeNode->getDirectory()) {
                    chdir($execDir);
                }

                // check if the configured script is a file
                if (is_file($script) && is_executable($script)) {
                    // initialize the exec params
                    $output = array();
                    $returnVar = 0;

                    // execute the script on the command line
                    exec($executeNode, $output, $returnVar);

                    // restore the old directory
                    if ($execDir && $actualDir) {
                        chdir($actualDir);
                    }

                    // query whether the script has been executed or not
                    if ($returnVar !== 0) {
                        throw new \Exception(implode(PHP_EOL, $output));
                    } else {
                        error_log(implode(PHP_EOL, $output));
                    }

                } else {
                    throw new \Exception(sprintf('Script %s is not a file or not executable', $script));
                }

            } else {
                throw new \Exception(sprintf('Can\t find a script configured in job', $this->jobNode->getName()));
            }

        } catch (\Exception $e) {
            // restore the old directory
            chdir($actualDir);
            // log the exception
            error_log($e->__toString());
        }
    }
969696
public function run() {
		$cwd = $this->cwd;

		$descriptors = array(
			0 => STDIN,
			1 => array( 'pipe', 'w' ),
			2 => array( 'pipe', 'w' ),
		);

		$proc = proc_open( $this->command, $descriptors, $pipes, $cwd, $this->env );

		$stdout = stream_get_contents( $pipes[1] );
		fclose( $pipes[1] );

		$stderr = stream_get_contents( $pipes[2] );
		fclose( $pipes[2] );

		return new ProcessRun( array(
			'stdout' => $stdout,
			'stderr' => $stderr,
			'return_code' => proc_close( $proc ),
			'command' => $this->command,
			'cwd' => $cwd,
			'env' => $this->env
		) );
	}
944682
public function run() {
        $results = [
            $this->doDelete(),
            $this->doUpdate(),
            $this->doCreate()
        ];
        return array_search(false, $results, true) === false;
    }
1180756
public function run(): array
    {
        try {
            $result = null;
            if ($this->match !== false && is_callable($this->match['target']) === true) {
                if (func_num_args() > 0) {
                    foreach (func_get_args() as $argument) {
                        $this->match['params'][] = $argument;
                    }
                } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) === false) {
                    $this->match['params'][] = $_POST;
                } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && empty($_GET) === false) {
                    $this->match['params'][] = $_GET;
                } elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') {
                    $_PUT = parse_str(file_get_contents("php://input"));
                    if (empty($_PUT) === false) {
                        $this->match['params'][] = $_PUT;
                    }
                } elseif ($_SERVER['REQUEST_METHOD'] == 'PATCH') {
                    $_PATCH = parse_str(file_get_contents("php://input"));
                    if (empty($_PATCH) === false) {
                        $this->match['params'][] = $_PATCH;
                    }
                }
                $result = call_user_func_array($this->match['target'], $this->match['params']);
            } else {
                throw new \InvalidArgumentException("Method not found");
            }
            return $result;
        } catch (\Throwable $e) {
            if ($e instanceof \InvalidArgumentException) {
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 400',
                            true,
                            400
                        ]
                    ],
                    "response" => $e->getMessage()
                ];
            } elseif ($e instanceof \DomainException) {
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 422',
                            true,
                            422
                        ]
                    ],
                    "response" => $e->getMessage()
                ];
            } else {
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 500',
                            true,
                            500
                        ]
                    ],
                    "response" => $e->getMessage()
                ];
            }
        }
    }
564875
public function run()
	{
		$this->say("Copying CLI files " . $this->source);

		if (!file_exists($this->source))
		{
			$this->say("Folder " . $this->source . " does not exist!");

			return true;
		}

		$this->prepareDirectory();

		$map = $this->copyTarget($this->source, $this->target);

		$this->setResultFiles($map);

		return true;
	}
158802
public function executeCommand()
    {
        $this->adapter->setCommandArray($this->commandArray);
        $result = $this->adapter->execute();
        $commandArrayUsed = $this->adapter->getCommandArray();
        $this->clearCommandArray();
        $this->checkResultForError($result, $commandArrayUsed);
        return $result;
    }
1173487
protected function runCommands()
    {
        // Load Remote directory
        $remote    = $this->argument('remote');
        $directory = Config::get('remote.connections.'.$remote.'.root');

        // Define commands
        $commands = array_merge(['cd '.$directory], Config::get('vdeploy::config.commands'));
        $commands = array_filter($commands);

        // Parse tags in command
        if (!$this->parseTags($commands)) {
            return false;
        }

        // Run Commands
        SSH::into($remote)->run($commands);

        return true;
    }
959795
public function run()
    {
        $current = [];
        if ($this->config['loadEnv']) {
            $current = $this->envLoader->parse();
        }

        foreach ($this->questions as $name => $question) {
            // If We got an answer out of the loaded env, then let's use it.
            $default = isset($current[$name]) ? $current[$name] : $question['default'];

            // Ask the question.
            $this->answers[$name] = $this->io->ask($name, $question['prompt'], $default, $question['required']);
        }

        return $this->answers;
    }
153137
public function execute() {
		$this->log->debug ( "AbstractCommand (" . get_class ( $this ) . "): command array: {" . implode ( ",", $this->cmd ) . "}" );
		$this->executeImpl ( $this->cmd );
		
		if ($this->response_to_source_channel) {
			$this->log->debug ( "AbstractCommand (" . get_class ( $this ) . "): requesting channel name for channel: " . $this->post ["channel_id"] );
			$this->result->setChannel ( Util::getChannelName ( $this->config, $this->post ["channel_id"] ) );
		}
		return $this->result;
	}
64193
public function run() {

        foreach ( $this->requests as $request ) {

            if ( isset($request['ERROR_CODE']) && isset($request['ERROR_MESSAGE']) ) {

                $this->logger->warning("Invalid request ".$request['ID']);

                $result = self::packJsonError($request['ERROR_CODE'], $request['ERROR_MESSAGE'], $request['ID']);

                if ( !is_null($result) ) $this->results[] = $result;

            } else {

                try {

                    $this->logger->debug("Serving request ".$request['METHOD']."(".$request['ID'].")");

                    $response = $this->runSingleRequest($request['METHOD'], $request['PARAMETERS']);

                    $result = self::packJsonSuccess($response, $request['ID']);

                } catch (RpcException $re) {

                    $this->logger->warning("Error handling request ".$request['ID'].": ".$re->getMessage());

                    $result = self::packJsonError($re->getCode(), $re->getMessage(), $request['ID']);

                } catch (Exception $e) {

                    $this->logger->error($e->getMessage());

                    throw $e;

                }

                if ( !is_null($result) ) $this->results[] = $result;

            }


        }

        if ( empty($this->results) ) {

            return null;

        } else if ( $this->is_batch_request ) {

            return $this->results;

        } else {

            return $this->results[0];

        }

    }
1303307
public function run()
    {
        $container = $this->getContainer();
        
        foreach ($this->exercises as $exercise) {
            if (false === $container->has($exercise)) {
                throw new \RuntimeException(
                    sprintf('No DI config found for exercise: "%s". Register a factory.', $exercise)
                );
            }
        }

        $checkRepository = $container->get(CheckRepository::class);
        foreach ($this->checks as $check) {
            if (false === $container->has($check)) {
                throw new \RuntimeException(
                    sprintf('No DI config found for check: "%s". Register a factory.', $check)
                );
            }

            $checkRepository->registerCheck($container->get($check));
        }

        if (!empty($this->results)) {
            $resultFactory = $container->get(ResultRendererFactory::class);

            foreach ($this->results as $result) {
                $resultFactory->registerRenderer($result['resultClass'], $result['resultRendererClass']);
            }
        }

        try {
            $exitCode = $container->get(CommandRouter::class)->route();
        } catch (MissingArgumentException $e) {
            $container
                ->get(OutputInterface::class)
                ->printError(
                    sprintf(
                        'Argument%s: "%s" %s missing!',
                        count($e->getMissingArguments()) > 1 ? 's' : '',
                        implode('", "', $e->getMissingArguments()),
                        count($e->getMissingArguments()) > 1 ? 'are' : 'is'
                    )
                );
            return 1;
        } catch (\RuntimeException $e) {
            $container
                ->get(OutputInterface::class)
                ->printError(
                    sprintf(
                        '%s',
                        $e->getMessage()
                    )
                );
            return 1;
        }
        return $exitCode;
    }
895850
public function run()
	{
		// Trigger event!
		$this->dispatch($this->listeners[self::LISTENER_STARTUP], [$this]);

		// Create initial request & response (PSR7!)
		$request = $this->createInitialRequest();
		$response = $this->createInitialResponse();

		try {
			// Trigger event!
			$this->dispatch($this->listeners[self::LISTENER_REQUEST], [$this, $request, $response]);

			// Right to the cycle
			$response = call_user_func(
				$this->chain,
				$request,
				$response,
				function (ServerRequestInterface $request, ResponseInterface $response): ResponseInterface {
					return $response;
				}
			);

			// Response validation check
			if (!isset($response) || $response === null) {
				throw new RuntimeException('Final response cannot be NULL or unset');
			}
		} catch (Throwable $e) {
			// Trigger event! In case of manual handling error, returned object is passed.
			$res = $this->dispatch($this->listeners[self::LISTENER_ERROR], [$this, $e, $request, $response]);
			if ($res !== null && $res !== false) {
				return $res;
			}

			// Throw exception again if it's not caught
			if ($this->catchExceptions !== true) {
				throw $e;
			}
		}

		// Trigger event! In case of manual finalizing, returned object is passed.
		$res = $this->dispatch($this->listeners[self::LISTENER_RESPONSE], [$this, $request, $response]);
		if ($res !== null && $res !== false) {
			return $res;
		}

		// Send to finalizer (simple send response)
		return $this->finalize($request, $response);
	}
644429
public function toArray() : array {
        return [
            'command'   => $this->getCommand(),
            'running'   => $this->isRunning(),
            'info'      => $this->getInfo() ? $this->getInfo()->toArray() : null,
        ];
    }