{@inheritdoc}

@param string|callable $run
@param array $arguments

@return Task
511820
public function run($run, array $arguments = [])
    {

        $lambda = new Lambda($run);

        return $this->repository->transaction(function($repo) use ($lambda, $arguments) {

            $taskTemplate = $this->newTask($lambda);

            $this->callBeforeListeners('run', [$taskTemplate, $lambda, $arguments]);

            $task = $this->repository->create($taskTemplate);

            $job = $this->createJob($task, $lambda, $arguments);

            // We can just ignore to write state because typically the job
            // is typically started in another process
            $task->setJob($job);

            $this->callAfterListeners('run', [$taskTemplate, $job]);

            return $task;

        });
    }
154238
public function call($class, $task, Arguments $arguments, Output $output)
	{
		// Namespace class
		$class = Arguments::routeCommand($class);

		// Say no to infinite nesting!
		$backtrace = debug_backtrace();
		$previous  = $backtrace[1];
		$prevClass = $previous['class'];
		$prevTask  = $previous['function'];

		if ($prevClass == $class && $prevTask == $task)
		{
			$output->error('You\'ve attempted to enter an infinite loop. We\'ve stopped you. You\'re welcome.');
		}

		// If task is help, set the output to our output class with extra methods for rendering help doc
		if ($task == 'help')
		{
			$output = $output->getHelpOutput();
		}

		$command = new $class($output, $arguments);

		$command->{$task}();
	}
776095
public function runCommand(Command $command, InputInterface $input, OutputInterface $output) {
    return $this->doRunCommand($command, $input, $output);
  }
469666
public function start(array $tasks)
    {
        foreach ($tasks as $task) {
            if (!isset($this->tasks[$task])) {
                throw new \RuntimeException('The task "' . $task . '" does not exists.');
            }

            Output::out(sprintf(
                '[%s] Starting task "%s"',
                Output::colorize((new \DateTime())->format('H:i:s'), 'light_gray'),
                Output::colorize($task, 'light_cyan')
            ));

            $start = microtime(true);
            $callback = $this->tasks[$task];
            $callback($this);

            Output::out(sprintf(
                '[%s] Task "%s" has finished in %s',
                Output::colorize((new \DateTime())->format('H:i:s'), 'light_gray'),
                Output::colorize($task, 'light_cyan'),
                Output::colorize(
                    sprintf(
                        '%s seconds',
                        round(microtime(true) - $start, 4)
                    ),
                    'magenta'
                )
            ));
        }
    }
32726
public function call($command, array $parameters = array())
	{
		$parameters['command'] = $command;

		$this->lastOutput = new BufferedOutput;

		return $this->find($command)->run(new ArrayInput($parameters), $this->lastOutput);
	}
560151
public function start(Context $context, array $args = []): Promise
    {
        $factory = $context->lookup(ProcessFactory::class);
        
        if ($factory === null) {
            throw new \RuntimeException('Cannot launch an async process without a process factory');
        }
        
        $options = [];
        
        foreach ($this->options as $k => $v) {
            if (\strlen($k) === 1) {
                $name = '-' . $k;
            } else {
                $name = '--' . $k;
            }
            
            if ($v === null) {
                $options[] = $name;
            } else {
                foreach ($v as $val) {
                    $options[] = $name;
                    $options[] = $val;
                }
            }
        }
        
        return $context->task($factory->createProcess($context, $this->command, \array_merge($options, $args), $this->dir, $this->env));
    }
327213
protected function executeCommand(OutputInterface $output, $name, $args = [])
    {
        array_unshift($args, 'internal');

        $return = $this->getApplication()->find($name)->run(new ArrayInput($args), $output);

        if (0 !== $return) {
            throw new \RuntimeException(sprintf("An error occured when executing command '%s'", $name), 30);
        }

        return $this;
    }
786592
public function run($tasks)
    {
        $tasks = is_array($tasks) ? $tasks : [$tasks];
        $queue = $this->builder->buildTasks($tasks);
        $pipeline = $this->buildPipeline($queue);

        // Wrap job in closure pipeline
        foreach ($pipeline as $key => $job) {
            $pipeline[$key] = function () use ($job) {
                return $this->executeJob($job);
            };
        }

        // Run the tasks and store the results
        if ($this->getOption('parallel')) {
            $pipeline = $this->runAsynchronously($pipeline);
        } else {
            $pipeline = $this->runSynchronously($pipeline);
        }

        return $pipeline;
    }
691
static public function launch($config, $run = true)
	{
		if (is_string($config)) {
		    $config = ['basePath' => $config];
		}
		
		$app = new static($config);
		
		if ($run) {
		    return $app->run();
		}
		
		return $app;
	}
1275188
public function build($name, $target, Array $files, Array $args = array())
    {
        if (empty($this->tasks[$name])) {
            throw new \RuntimeException("Don't konw how to build {$name}");
        }

        $watching = array_merge([$target], $files);
        if (!$this->needBuilding($target, $watching)) {
            return $target;
        }

        $this->stack[] = $target;
        $this->tasks[$name]->exec($target, $files, $args, $this);
        array_pop($this->stack);

        $this->watchFiles($target, $watching);

        $this->isDry = true;
        return $target;
    }
960936
public static function run($autoRun = true, InputInterface $input = null, OutputInterface $output = null)
    {
        $console = new Application('');
        $def = new ListCommand();
        $console->add($def);
        $console->setDefaultCommand($def->getName());

        $console->addCommands(self::getCommands());
        if (null === $output) {
            $output = new ConsoleOutput();
        }
        self::warningText($output);
        self::errorText($output);

        if ($autoRun) {
            $console->run($input, $output);
        }

        return $console;
    }
537534
public function execute(callable $function, array $arguments = [])
    {
        $delayFunction = $this->delayFunction;
        $calcDelayFunction = $this->calcDelayFunction ?: [$this, 'calculateDelay'];
        $retryAttempt = 0;
        $exception = null;

        while (true) {
            try {
                return call_user_func_array($function, $arguments);
            } catch (\Exception $exception) {
                if ($this->retryFunction) {
                    if (!call_user_func($this->retryFunction, $exception)) {
                        throw $exception;
                    }
                }

                if ($retryAttempt >= $this->retries) {
                    break;
                }

                $delayFunction($calcDelayFunction($retryAttempt));
                $retryAttempt++;
            }
        }

        throw $exception;
    }
193751
public function runFileGeneratorCommand($path, $argument)
    {
        if ($this->filesystem->exists($path)) {
            return 'File with the name '.$argument.' already exist';
        }
        $folder_name = explode('/', $argument);
        $folder = '';
        if (count($folder_name) > 1) {
            $folder_path = array_slice($folder_name, 0, -1);
            foreach ($folder_path as $f) {
                $folder .= "$f/";
            }
            $filename = end($folder_name);
        } else {
            $filename = $argument;
        }
        $folder ? $location = "$this->basePath/$folder/$filename.php" : $location = "$this->basePath/$filename.php";
        $template = $this->findTemplateAndReplacePlaceHolders('PlaceHolder', $filename,
            file_get_contents($this->getTemplate($this->type))
        );
        $this->filesystem->dumpFile($location, $template);

        return true;
    }
154622
public function run($command, array $parameters = [])
    {
        if (\is_string($command) && \count($parameters)) {
            $command .= ' ' . $this->compileParameters($parameters);
        }

        $this->events[] = $event = new Event($this->id(), $command);

        return $event;
    }
1108157
public function run(string $name, $parameters = null)
    {
        if ($this->enabled && $this->has($name)) {
            $this->getSwoole()->task([
                'name' => $name,
                'parameters' => $parameters
            ]);
        }
    }
1317812
private function processStreamCallback(string $task, ...$params)
    {
        if (! isset($this->stream)) {
            throw new \RuntimeException('Stream is detached');
        }

        $task = strtolower($task);
        $fn = 'f';
        if ($this->streamType === 'ZLIB') {
            if ($task === 'stat') {
                return false;
            }
            $fn = 'gz';
        }
        // default using f$task -> eg fopen() on gzip using gzopen
        $fn   .= $task;
        if (! function_exists($fn)) {
            return false;
        }
        switch ($task) {
            case 'seek':
            case 'write':
                if ($task === 'seek' && ! $this->seekable) {
                    throw new \RuntimeException('Stream is not seekable');
                } elseif ($task === 'write' && ! $this->writable) {
                    throw new \RuntimeException('Cannot write to a non-writable stream');
                }

                if (isset($params[1])) {
                   return $fn($this->stream, $params[0], $params[1]);
                }
                return $fn($this->stream, $params[0]);
            case 'read':
                return $fn($this->stream, $params[0]);
            default:
                return $fn($this->stream, ...$params);
        }
    }
1260228
public function run($operation, array $arguments=[])
    {
        $job = $this->createJob($this->attributes, $operation, $arguments);
        return $this->pushToChannel($job);
    }