Execution.

@param InputInterface  $input  Input console
@param OutputInterface $output Output console

@return int Exit code
500324
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $start = microtime(true);
        $provider = new Provider();
        $commands = $provider->getCommands();
        $style = new SymfonyStyle($input, $output);
        $style->setDecorated(true);
        $output->write(sprintf("\033\143"));
        $style->title('Running all');
        $ignore = array('qa:all', 'qa:fixer', 'qa:paratest');

        foreach ($commands as $command) {
            $name = $command->getName();
            if (in_array($name, $ignore) || strlen($name) < 7) {
                continue;
            }

            $arguments = array(
                'command' => $name,
            );

            $startCommand = microtime(true);
            $output->write('<info>Running '.$name.'</>');
            $returnCode = $this->getApplication()->find($command->getName())->run(
                new ArrayInput($arguments),
                new NullOutput()
            );
            $endCommand = microtime(true);
            $timeCommand = round($endCommand - $startCommand);
            $output->write(' - '.$timeCommand.' secs');

            if ($returnCode) {
                $output->write(' - <error>exit code '.$returnCode.'</>');
            }

            $style->newLine();
            if ($input->getOption('stop-on-failure')) {
                return $returnCode;
            }
        }

        $end = microtime(true);
        $time = round($end - $start);
        $style->newLine();
        $style->section('Results');
        $output->writeln('<info>Time: '.$time.' seconds</>');
    }
946925
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
        $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
        $errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);

        $context = json_decode($input->getOption('context') ?: '{}', true);
        $context['tenant_id'] = (string)$input->getOption('tenant-id');

        $nodeRef = NodeRef::fromString($input->getArgument('node-ref'));
        $consistent = $input->getOption('consistent') ? true : false;

        try {
            $node = $this->ncr->getNode($nodeRef, $consistent, $context);
            echo json_encode($node, $input->getOption('pretty') ? JSON_PRETTY_PRINT : 0) . PHP_EOL;
        } catch (\Throwable $e) {
            $errOutput->writeln($e->getMessage());
        }
    }
51852
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $this->createOutput($input, $output);

        $this->getFacade()->runInstall(
            $this->getCommandLineArgumentContainer(),
            $this->getCommandLineOptionContainer(),
            $this->output
        );

        return 0;
    }
705578
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->startCommand($output);

        $configurationIdentifier = $input->getArgument('identifier');
        $this
            ->configurationManager
            ->delete(
                $configurationIdentifier
            );

        $this->printMessage(
            $output,
            'Configuration',
            'Deleted configuration "' . $configurationIdentifier . '"'
        );

        $this->finishCommand($output);
    }
1259806
protected function execute(InputInterface $input, OutputInterface $output)
    {
        // {{
        $this->title('配置信息');
        // }}

        $this->treeView(Config::get(''));
        $this->newLine();

        return 0;
    }
965828
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->startCommand($output);

        $configurationIdentifier = $input->getArgument('identifier');
        $configurationValue = json_encode($this
            ->configurationManager
            ->get($configurationIdentifier));

        $this->printMessage(
            $output,
            'Configuration',
            $configurationIdentifier . ' : "' . $configurationValue . '"'
        );

        $this->finishCommand($output);
    }
136572
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $start = microtime(true);
        $style = new SymfonyStyle($input, $output);
        $style->setDecorated(true);
        $style->title($this->description);

        $util = new Util();
        $source = $util->checkSource($input);
        if ($input->getOption('diff')) {
            $source = $util->getDiffSource();
        }

        $sources = $this->getAllFiles(explode(' ', $source));
        $exitCode = 0;
        $columnSize = 80;
        $errors = '';
        foreach ($sources as $line => $source) {
            if (($line % $columnSize) == 0) {
                $style->newLine();
            }

            $cmd = 'php -l '.$source;
            $process = new Process($cmd);
            $process->setTimeout(3600)->run(function ($type, $buffer) use ($style, &$errors) {
                if (strpos($buffer, 'No syntax errors') !== false || Process::ERR == $type) {
                    $style->write('.');

                    return;
                }

                $style->write('<error>E</>');
                $errors = $buffer;
            });

            if (!$exitCode) {
                $exitCode = $process->getExitCode();
            }
        }

        $end = microtime(true);
        $time = round($end - $start);

        $style->newLine();
        $output->write($errors);
        $style->newLine();

        $style->section('Results');
        $output->writeln('<info>Command: php -l FILE</>');
        $output->writeln('<info>Files: '.count($sources).'</>');
        $output->writeln('<info>Time: '.$time.' seconds</>');
        $style->newLine();

        return $exitCode;
    }
341480
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;

        $curie = SchemaCurie::fromString($input->getArgument('curie'));
        $_SERVER['REQUEST_METHOD'] = 'POST';
        $_SERVER['CONTENT_TYPE'] = 'application/json';
        $_SERVER['HTTP_ACCEPT'] = 'application/json';
        $_SERVER['HTTP_ACCEPT_CHARSET'] = 'utf-8';
        $_SERVER['HTTP_USER_AGENT'] = $input->getOption('user-agent') ?: 'pbjx-console/0.x';

        $deviceView = $input->getOption('device-view');
        if (!empty($deviceView)) {
            $_SERVER['DEVICE_VIEW'] = $deviceView;
            putenv('DEVICE_VIEW=' . $deviceView);
        }

        $request = Request::create(
            sprintf(
                '/pbjx/%s/%s/%s/%s',
                $curie->getVendor(),
                $curie->getPackage(),
                $curie->getCategory() ?: '_',
                $curie->getMessage()
            ),
            $_SERVER['REQUEST_METHOD'],
            [], // GET and POST (aka $_REQUEST)
            $_COOKIE,
            $_FILES,
            $_SERVER,
            $input->getArgument('json') ?: '{}'
        );

        /*
         * prepare the request object so http and console processing are virtually the same
         */
        $request->setRequestFormat('json');
        $request->attributes->set('pbjx_vendor', $curie->getVendor());
        $request->attributes->set('pbjx_package', $curie->getPackage());
        $request->attributes->set('pbjx_category', $curie->getCategory());
        $request->attributes->set('pbjx_message', $curie->getMessage());
        $request->attributes->set('pbjx_bind_unrestricted', true);
        $request->attributes->set('pbjx_console', true);
        if (!empty($deviceView)) {
            $request->attributes->set('device_view', $deviceView);
        }

        $this->useInMemoryTransports($input);
        $this->getRequestStack()->push($request);
        $envelope = $this->getPbjxController()->handleAction($request);

        try {
            $this->getPbjx()->triggerLifecycle($envelope, false);
        } catch (\Throwable $e) {
            /*
             * write to std error but return payload as is.  Decorating the envelope
             * is not typically an exception worthy condition.
             */
            $errOutput->writeln('<error>' . $e->getMessage() . '</error>');
        }

        $envelope->set('ok', Code::OK === $envelope->get('code'));
        $output->writeln(json_encode($envelope, $input->getOption('pretty') ? JSON_PRETTY_PRINT : 0));
    }
579477
protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $this->input  = $input;
        $this->output = $output;
        $this->io     = new SymfonyStyle($this->input, $this->output);

        return $this->go();
    }
468924
protected function execute(InputInterface $input, OutputInterface $output) : ?int
    {
        $loggerHelper = new LoggerHelper();
        $logger       = $loggerHelper->create($output);

        /** @var string $resources */
        $resources = $input->getOption('resources');

        $failed  = false;
        $command = $this->getApplication()->find('validate-browsers');

        $input = new ArrayInput(
            [
                'command' => 'validate-browsers',
                '--resources' => $resources,
            ]
        );

        $returnCode = $command->run($input, $output);

        if (0 < $returnCode) {
            $logger->error('There was an error executing the "validate-browsers" command, cannot continue.');

            $failed = true;
        }
        $command = $this->getApplication()->find('validate-devices');

        $input = new ArrayInput(
            [
                'command' => 'validate-devices',
                '--resources' => $resources,
            ]
        );

        $returnCode = $command->run($input, $output);

        if (0 < $returnCode) {
            $logger->error('There was an error executing the "validate-devices" command, cannot continue.');

            $failed = true;
        }

        $command = $this->getApplication()->find('validate-engines');

        $input = new ArrayInput(
            [
                'command' => 'validate-engines',
                '--resources' => $resources,
            ]
        );

        $returnCode = $command->run($input, $output);

        if (0 < $returnCode) {
            $logger->error('There was an error executing the "validate-engines" command, cannot continue.');

            $failed = true;
        }

        $command = $this->getApplication()->find('validate-platforms');

        $input = new ArrayInput(
            [
                'command' => 'validate-platforms',
                '--resources' => $resources,
            ]
        );

        $returnCode = $command->run($input, $output);

        if (0 < $returnCode) {
            $logger->error('There was an error executing the "validate-platforms" command, cannot continue.');

            $failed = true;
        }

        $command = $this->getApplication()->find('validate-core-divisions');

        $input = new ArrayInput(
            [
                'command' => 'validate-core-divisions',
                '--resources' => $resources,
            ]
        );

        $returnCode = $command->run($input, $output);

        if (0 < $returnCode) {
            $logger->error('There was an error executing the "validate-core-divisions" command, cannot continue.');

            $failed = true;
        }

        $command = $this->getApplication()->find('validate-divisions');

        $input = new ArrayInput(
            [
                'command' => 'validate-divisions',
                '--resources' => $resources,
            ]
        );

        $returnCode = $command->run($input, $output);

        if (0 < $returnCode) {
            $logger->error('There was an error executing the "validate-divisions" command, cannot continue.');

            $failed = true;
        }

        if (!$failed) {
            $output->writeln('the files are valid');
        }

        return (int) $failed;
    }
141558
protected function execute(InputInterface $input, OutputInterface $output): ?int
    {
        $username = $this->getUsername($input, $output);
        if ($input->getOption('if-not-exists')) {
            try {
                $user = $this->userManager->loadUserByUsername($username);
            } catch (\Exception $e) {
                $user = null;
            }
            if ($user) {
                $message = $this->translator->trans(
                    'user.already_exists',
                    [
                        '%username%' => $username,
                    ],
                    'security'
                );
                $output->writeln("<comment>{$message}</comment>");

                return 0;
            }
        }

        try {
            $user = $this->userManager->createUser($username);
        } catch (BadUsernameException $e) {
            $output->writeln("<error>{$e->getMessage()}</error>");

            return 1;
        }

        $user->setSuperAdmin($input->getOption('admin'));
        $password = $this->getPassword($input, $output);
        if ($password) {
            $this->userManager->setPlainTextPassword($user, $password);
        }
        $this->userManager->save($user);

        $message = $this->translator->trans('user.created_success', ['%username%' => $username], 'security');
        $output->writeln("<info>{$message}</info>");

        return 0;
    }
967208
public function doRun(InputInterface $input, OutputInterface $output)
	{
		$this->io = new ConsoleIO($input, $output, $this->getHelperSet());
		ErrorHandler::register($this->io);

		return parent::doRun($input, $output);
	}
1367874
public function execute(Input $input, Output $output) {
        //$input = Console::input();//new Input();
        //$output = Console::output();//new Output();

        $this->configureIO($input, $output);

        $exitCode = $this->doRun($input, $output);

        return $exitCode;

        try {
            $exitCode = $this->doRun($input, $output);
        }
        catch (\Exception $e) {
            if (!$this->catchExceptions) {
                throw $e;
            }

            $output->renderException($e);

            $exitCode = $e->getCode();
            if (is_numeric($exitCode)) {
                $exitCode = (int)$exitCode;
                if (0 === $exitCode) {
                    $exitCode = 1;
                }
            }
            else {
                $exitCode = 1;
            }
        }

        if ($this->autoExit) {
            if ($exitCode > 255) {
                $exitCode = 255;
            }

            exit($exitCode);
        }

        return $exitCode;
    }
594086
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $output;

        try {
            return $this->fire();
        } catch (DomainException $e) {
            return 1;
        } catch (Exception $e) {
            $this->error($e->getMessage());
            $this->error('Abort!');
        }

        return;
    }
1260613
protected function execute(InputInterface $input, OutputInterface $output) {
		$action = $input->getArgument('action');
		if (!is_callable([ $this, $action ])) {
			$output->writeln('<error>Please specify a valid action: start/stop/status</error>');
			return 1;
		}
		return $this->$action($input, $output);
	}
840413
protected function execute( InputInterface $input, OutputInterface $output ) {
		$this->output = $output;
		$this->input = $input;
		$path = $this->setup();
		if ( is_int( $path ) ) {
			return $path;
		}
		$err = $this->loadConfig( $path );
		if ( is_int( $err ) ) {
			return $err;
		}

		$output->writeln( "Processing $path..." );
		$bad = $this->checkPath( $path );
		$output->write( "\n" );
		if ( $bad ) {
			foreach ( $bad as $file ) {
				$output->writeln( "Error: {$file->getPathname()} should not be executable" );
			}
			return 1;
		} else {
			$output->writeln( 'All good!' );
			return 0;
		}
	}
503861
public function execute(InputInterface $input, OutputInterface $output)
    {
        $this->output = $output;
        try {
            $this->doExecute($input, $output);
        } catch (\Exception $e) {
            $this->writeException($e);
        }
    }