Run command

@return void return from MAIN CLTool
480905
function run()
    {
        if (isset($this->arg[0])) {
            $this->arg[0] = str_replace('\\', '/', $this->arg[0]);
        } else {
            return "\n\n  ERROR: indique o NOME do arquivo!\n";
        }

        $type = strtolower(trim($this->cmd));

        if ($type != 'controller' && $type != 'model' && $type != 'html') {
            echo "\n\n  Command \"make:".$this->cmd."\" not exists!";
            exit(Main::help());
        }

        return $this->createFile($this->arg[0], $type);
    }
144392
protected function start() {
        $args = $this->getServerArguments();
        if ($args['command']) {
            $commandClass = $this->getCommandClassFromNameAndModule($args['command'], null);
        } else {
            $commandClass = $this->notFoundCommand;
        }
        if (!class_exists($commandClass)) {
            $this->alert('Command ' . $commandClass . ' not found!', array(
                'requestedCommand' => $args['command'],
                'requestedModule' => '-'
            ));
            $commandClass = $this->notFoundCommand;
        }

        $command = $this->loadCommand($commandClass);
        $command->setActiveAction($args['action']);
        $command->run($args['params']);
    }
1077625
public function runAndReload()
    {

        // start supervisor and reload configuration
        $commands = [];
        $commands[] = sprintf(' && %s', $this->createSupervisorControlCommand('reread'));
        $commands[] = sprintf(' && %s', $this->createSupervisorControlCommand('update'));
        $this->run(implode('', $commands));
    }
215317
public function run()
    {
        $defaultCommand = null;
        $command        = null;

        if ($this->defaultCommand) {
            $defaultCommand = $this->getCommand($this->defaultCommand);
        }
        if (!$this->shouldOnlyUseDefaultCommand()) {
            $commandName = $this->parameter->getCommandName();
            if ($commandName) {
                $command = $this->getCommand($commandName);
            }
            $this->parameter->enableCommandName();
        } else {
            $this->parameter->disableCommandName();
        }

        // Use $command or $defaultCommand, since they're mutually exclusive
        $command = $command ?: $defaultCommand;

        if (!$command) {
            throw new \Parable\Console\Exception('No valid commands found.');
        }

        $this->activeCommand = $command;

        $this->parameter->setCommandArguments($command->getArguments());
        $this->parameter->checkCommandArguments();

        $this->parameter->setCommandOptions($command->getOptions());
        $this->parameter->checkCommandOptions();

        return $command->run();
    }
1007018
protected function doRun()
    {
        $result = 0;
        $args = func_get_args();
        $host = $this->session->getHost();

        if (count($args) === 3) {
            list($method, $params, $retval) = $args;

            // Strip namespace 
            $method = trim(str_replace(__NAMESPACE__, '', $method),'\\');
            $command = $method.' => ['.implode(' , ', $params).']';
            $this->printOut('<comment>' . $host . '</comment> < <info>' . $command.'</info>');

            // Initial result evaluation
            $result = $retval;
            $halt = $result == false;

            // Prints process information
            // @codeCoverageIgnoreStart
            if ($halt) {
                $this->printOut('<error>Aborted</error>');
            } else {
                if (is_string($retval) || is_array($retval)) {

                    if(is_array($retval)) {
                        foreach ($retval as $key => $val) {
                            if ( ! is_numeric($key)) $resultDioArray[] = $key.':'.$val;
                        }
                    } else {
                        $resultDioArray = array_filter(explode("\n", $retval));
                    }


                    foreach ($resultDioArray as $i => $resultDioLine) {
                        $this->printOut((($i === 0) ? '<comment>'.$host.'</comment>' : str_pad(' ', strlen($host))).' > <info>'.$resultDioLine.'</info>');
                    }
                } else {
                    $this->printOut('<comment>'.$host.'</comment> > <info>[OK]</info>');
                }
            }
            // @codeCoverageIgnoreEnd
        }

        return $result;
    }
70409
public function run()
    {
        $result = $this->executeCommand($this->getCommand());
        return !$result->wasSuccessful() && $this->failOnViolations
            ? $result
            : \Robo\Result::success($this, $result->getMessage(), $result->getData());
    }
702327
public function run()
    {
        // from install folder
        if (! file_exists($this->parameters['previous'])) {
            $this->err('Previous tao directory "' . $this->parameters['previous'] . '" found', true);
        }
        
        $outDir = $this->parameters['output'];
        if (! file_exists($outDir)) {
            if (! mkdir($outDir)) {
                $this->err('Could not create directory "' . $outDir, true);
            }
        }
        
        $oldExts = $this->getAllExtensionManifests($this->parameters['previous']);
        $newExts = $this->getAllExtensionManifests(ROOT_PATH);
        
        foreach ($oldExts as $extId => $manifest) {
            $extDiff = new taoDevTools_models_ExtDiff($manifest, isset($newExts[$extId]) ? $newExts[$extId] : null);
            file_put_contents($outDir . DIRECTORY_SEPARATOR . 'diff' . ucfirst($extId) . '.php', $extDiff->exportDiffToPhp());
            file_put_contents($outDir . DIRECTORY_SEPARATOR . 'diff' . ucfirst($extId) . '.sql', $extDiff->exportDiffToSql());
            if (! isset($newExts[$extId])) {
                $this->out('Extension ' . $extId . ' no longer exists.');
            }
        }
    }
886772
public function runInBackgroundCommand(): void
    {
        $script = '<?php print_r($_SERVER); ?>';
        $ret = Sys::execInBackground("php $script");

        if ($ret === false) {
            $this->output->liteError('current env is not support process create.');
        }
    }
428570
public function run()
    {
        $command = new \ReflectionClass($this);
        $options = input()->get();

        if (empty($options)) {
            if ($this->welcomeNote instanceof Format or $this->welcomeNote instanceof Text) {
                output()->write($this->welcomeNote);
            } elseif (is_string($this->welcomeNote) and $this->welcomeNote !== '') {
                output()->write(
                    (new Format())
                        ->setString(language()->getLine($this->welcomeNote))
                        ->setNewLinesAfter(1)
                );
            }

            output()->write(
                (new Format())
                    ->setString($this->name . ' v' . $this->version)
                    ->setNewLinesBefore(2)
                    ->setNewLinesAfter(1)
            );

            // Run help option
            $this->optionHelp();
        } else {

            foreach ($options as $method => $arguments) {

                if ($method === 'h') {
                    $method = 'help';
                } elseif ($method === 'v') {
                    $method = 'version';
                } elseif ($method === 'vv') {
                    $method = 'verbose';
                }

                $optionMethod = camelcase('option-' . $method);

                if ($command->hasMethod($optionMethod)) {

                    $commandMethod = $command->getMethod($optionMethod);

                    if ($commandMethod->getNumberOfRequiredParameters() == 0) {
                        call_user_func([&$this, $optionMethod]);
                    } else {
                        $optionArguments = is_array($arguments)
                            ? $arguments
                            : [$arguments];

                        call_user_func_array([&$this, $optionMethod], $optionArguments);
                    }
                }
            }
        }
    }
364517
public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        if (null === $input) {
            // rewrite the input for single command usage
            $argv = $_SERVER['argv'];
            $scriptName = array_shift($argv);
            array_unshift($argv, 'lint');
            array_unshift($argv, $scriptName);
            $input = new ArgvInput($argv);
        }

        return parent::run($input, $output);
    }
78279
public function run() {
		$isPost = $_SERVER["REQUEST_METHOD"] == 'POST';
		$src    = $_SERVER["REQUEST_METHOD"] == 'POST' ? $_POST : $_GET;
		if ($isPost && !$src && $rawPostData = @file_get_contents('php://input')) {
			// for support IE XDomainRequest()
			$parts = explode('&', $rawPostData);
			foreach($parts as $part) {
				list($key, $value) = array_pad(explode('=', $part), 2, '');
				$src[$key] = rawurldecode($value);
			}
			$_POST = $this->input_filter($src);
			$_REQUEST = $this->input_filter(array_merge_recursive($src, $_REQUEST));
		}
		$cmd    = isset($src['cmd']) ? $src['cmd'] : '';
		$args   = array();
		
		if (!function_exists('json_encode')) {
			$error = $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_JSON);
			$this->output(array('error' => '{"error":["'.implode('","', $error).'"]}', 'raw' => true));
		}
		
		if (!$this->elFinder->loaded()) {
			$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_VOL), 'debug' => $this->elFinder->mountErrors));
		}
		
		// telepat_mode: on
		if (!$cmd && $isPost) {
			$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UPLOAD, elFinder::ERROR_UPLOAD_TOTAL_SIZE), 'header' => 'Content-Type: text/html'));
		}
		// telepat_mode: off
		
		if (!$this->elFinder->commandExists($cmd)) {
			$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UNKNOWN_CMD)));
		}
		
		// collect required arguments to exec command
		foreach ($this->elFinder->commandArgsList($cmd) as $name => $req) {
			$arg = $name == 'FILES' 
				? $_FILES 
				: (isset($src[$name]) ? $src[$name] : '');
				
			if (!is_array($arg)) {
				$arg = trim($arg);
			}
			if ($req && (!isset($arg) || $arg === '')) {
				$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_INV_PARAMS, $cmd)));
			}
			$args[$name] = $arg;
		}
		
		$args['debug'] = isset($src['debug']) ? !!$src['debug'] : false;
		
		$this->output($this->elFinder->exec($cmd, $this->input_filter($args)));
	}
1042354
public function run()
    {
        if ($this->booted) {
            return;
        }
        
        // Boot kernel and console
        $this->kernel->withoutSession();
        $this->kernel->boot();
        
        $this->booted = true;

        foreach ($this->setting->getBootstrap() as $item) {
            require $item;
        }
        
        $command = $this->arg->getParameter('command');

        if (array_key_exists($command, $this->registers)) {
            return $this->registers[$command]($this->arg);
        }

        if ($command == 'launch') {
            $command = null;
        }

        if ($command == 'run') {
            $command = 'launch';
        }

        try {
            $this->call($command);
        } catch (ConsoleException $exception) {
            echo Color::red($exception->getMessage());
            exit(1);
        }
    }
320095
public function run()
    {
        $this->setupSignalHandlers();

        $procs = [];
        while (true) {
            $jobs = $this->runner->getJobs();
            foreach ($jobs as $job) {
                if (! array_key_exists($job->identifier(), $procs)) {
                    $procs[$job->identifier()] = [];
                }
                while (count($procs[$job->identifier()]) > $job->numWorkers()) {
                    // Stopping an excessive child.
                    echo 'Stopping an excessive child.' . PHP_EOL;
                    $proc = array_pop($procs[$job->identifier()]);
                    $status = proc_get_status($proc);
                    // Keep sending SIGTERM until the child exits.
                    while ($status['running'] === true) {
                        @proc_terminate($proc);
                        usleep(50000);
                        $status = proc_get_status($proc);
                    }
                    @proc_close($proc);
                }
                for ($i = 0; $i < $job->numWorkers(); $i++) {
                    $needStart = false;
                    if (array_key_exists($i, $procs[$job->identifier()])) {
                        $status = proc_get_status($procs[$job->identifier()][$i]);
                        if ($status['running'] !== true) {
                            $needStart = true;
                        }
                    } else {
                        $needStart = true;
                    }
                    if ($needStart) {
                        echo 'Starting a child.' . PHP_EOL;
                        $procs[$job->identifier()][$i] = proc_open(
                            sprintf('%s %d', $this->command, $job->id()),
                            $this->descriptorSpec,
                            $pipes
                        );
                    }
                }
            }
            usleep(1000000); // Reload the config after 1 second
            pcntl_signal_dispatch();
            if ($this->shutdown) {
                echo 'Shutting down, waiting for the children' . PHP_EOL;
                foreach ($procs as $k => $v) {
                    foreach ($v as $proc) {
                        $status = proc_get_status($proc);
                        // Keep sending SIGTERM until the child exits.
                        while ($status['running'] === true) {
                            @proc_terminate($proc);
                            usleep(50000);
                            $status = proc_get_status($proc);
                        }
                        @proc_close($proc);
                    }
                }
                echo 'BatchDaemon exiting' . PHP_EOL;
                exit;
            }
            // Reload the config
            $this->runner->loadConfig();
        }
    }
565182
public function run()
    {
        $argument        = Eurekon\Argument::getInstance();
        $directory       = (string) $argument->get('directory');
        $configName      = (string) $argument->get('item');
        $configNamespace = (string) $argument->get('namespace', null, 'global.database');
        $dbName          = (string) $argument->get('db');

        //~ Init db connection
        $container  = Container::getInstance();
        $config  = $container->get('config');
        Database::getInstance()->setConfig($config->get($configNamespace));

        $directory = realpath(trim(rtrim($directory, '\\')));
        $file      = $directory . DIRECTORY_SEPARATOR . 'orm.yml';

        if (!is_readable($file)) {
            throw new \LogicException('Configuration file for ORM not available!');
        }

        $yaml = new Yaml();
        $data = $yaml->load($file);

        $directory = $directory . DIRECTORY_SEPARATOR . $data['orm']['directory'];
        $namespace = $data['orm']['namespace'];

        if (!is_dir($directory) && !mkdir($directory, 0764, true)) {
            throw new \RuntimeException('Cannot created output directory! (dir:' . $directory . ')');
        }

        $configs = $this->findConfigs($file, $data, $configName, true);

        $builder = new Builder();
        $builder->setDatabase(Database::get($dbName));
        $builder->setNamespace($namespace);
        $builder->setDirectory($directory);
        $builder->build($configs);
    }
887884
public function run()
    {
        
        $userService = tao_models_classes_UserService::singleton();
        $this->outVerbose("Connecting to TAO as '" . $this->options['user'] . "' ...");
        if ($userService->loginUser($this->options['user'], $this->options['password'])){
        	$this->outVerbose("Connected to TAO as '" . $this->options['user'] . "'.");
        	
        	$filename = $this->options['input'];
        	$action = new ImportRdf();
        	$params = array($filename);
        	
        	if (!empty($this->options['model'])){
        	    $nameSpace = common_ext_NamespaceManager::singleton()->getNamespace($this->options['model']);
        	    $params[] = $nameSpace->getModelId();
        	}
        	 
        	$report = $action->__invoke($params);
        	
            $string = helpers_Report::renderToCommandline($report);
        	foreach (explode(PHP_EOL, $string) as $line) {
        	    $this->out($line);
        	}
        }
        else{
        	$this->err("Unable to connect to TAO as '" . $this->options['user'] . "'.", true);
        }
        
    }
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;
    }
1292791
public function run()
    {
        $cli = eZCLI::instance();

        if ( $this->optMemoryMonitoring == true )
        {
            eZLog::rotateLog( self::LOG_FILE );
            $cli->output( "Logging memory usage to " . self::LOG_FILE );
        }

        if ( $this->optIterationSleep > 0 )
            $sleep = ( $this->optIterationSleep * 1000000 );
        else
            $sleep = false;

        $limit = array( 0, $this->optIterationLimit );

        $cli->output( "Purging expired items:" );

        self::monitor( "start" );

        // Fetch a limited list of purge items from the handler itself
        $clusterHandler = eZClusterFileHandler::instance();
        while ( $filesList = $clusterHandler->fetchExpiredItems( $this->optScopes, $limit, $this->optExpiry ) )
        {
            self::monitor( "iteration start" );
            foreach( $filesList as $file )
            {
                $cli->output( "- $file" );
                if ( $this->optDryRun == false )
                {
                    self::monitor( "purge" );
                    $fh = eZClusterFileHandler::instance( $file );
                    $fh->purge( false, false );
                    unset( $fh );
                }
            }
            if ( $sleep !== false )
                usleep( $sleep );

            // the offset only has to be increased in dry run mode
            // since each batch is not deleted
            if ( $this->optDryRun == true )
            {
                $limit[0] += $limit[1];
            }
            self::monitor( "iteration end" );
        }

        self::monitor( "end" );
    }