Execute this command.

@return int

@since  2.0
@throws \Exception
161883
protected function doExecute()
    {
        $path = getcwd() . '/' . $this->getArgument(0);

        if (!is_file($path)) {
            throw new \RuntimeException('Not file');
        }

        $content = Yaml::parse(file_get_contents($path));
        $year = Chronos::create()->year;

        $content = PhpFormat::structToString(
            $content,
            [
                'header' => "/**
 * Part of Windwalker project.
 *
 * @copyright  Copyright (C) $year __ORGANIZATION__.
 * @license    __LICENSE__
 */"
            ]
        );

        $path = substr_replace($path, 'php', strrpos($path, '.') + 1);

        file_put_contents($path, $content);
        $this->out('Write to:' . $path);

        return true;
    }
81849
public function handle()
    {
        $url = $this->argument('url');

        try {
            list($vendorFolderName, $packageFolderName) = $this->getVendorAndFolderName($url);
        } catch (Exception $e) {
            $this->error($e->getMessage());

            return -1;
        }

        $vendor = $this->getVendor() ?: Str::title($vendorFolderName);
        $package = $this->getPackage() ?: Str::studly($packageFolderName);

        $relPackagePath = "packages/$vendorFolderName/$packageFolderName";
        $packagePath = base_path($relPackagePath);

        try {
            $this->cloneRepo($url, $packagePath, $this->option('branch'));
            $this->registerPackage($vendor, $package, $relPackagePath);
            $this->composerUpdatePackage($vendorFolderName, $packageFolderName);
            $this->composerDumpAutoload();

            $this->info('Finished.');
        } catch (Exception $e) {
            $this->error($e->getMessage());

            return -1;
        }

        return 0;
    }
611363
public static function handleCommand() {
        try {
            global $argv;
            $tokens = array_slice($argv, 1);

            if (empty($tokens)) {
                throw new RuntimeException("Command name is required !!");
            }

            $commandName = (string)$tokens[0];
            $commandTokens = array_slice($tokens, 1);

            $commandParameters = [];
            $currentCommandName = null;

            for ($i = 0; $i < sizeof($commandTokens); $i++) {
                $commandToken = $commandTokens[$i];

                if (substr($commandToken, 0, 2) == '--') {
                    if ($currentCommandName != null) {
                        $commandParameters[$currentCommandName] = true;
                    }
                    $currentCommandName = substr($commandToken, 2);
                }
                else {
                    if ($currentCommandName == null) {
                        throw new RuntimeException("Invalid argument \"$commandToken\". Arguments must start with \"--\"");
                    }
                    $commandParameters[$currentCommandName] = $commandToken;
                    $currentCommandName = null;
                }
            }

            if ($currentCommandName != null) {
                $commandParameters[$currentCommandName] = true;
            }

            self::executeCommand($commandName, $commandParameters);
        }
        catch (CommandNotFoundException $exception) {
            get_logger()->warning($exception->getMessage());
            echo $exception->getMessage() . "\n";
        }
    }
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();
    }
1135035
public function execute() {
        $value = curl_exec($this->handle);

        $error_no = curl_errno($this->handle);

        if (0 !== $error_no) {
            throw new CurlErrorException(curl_error($this->handle), $error_no);
        }

        return $value;
    }
297495
public function execute()
    {
        // Get the parameters
        $params = $this->getParams();

        // Get the url
        $url = $this->getUrl($params);

        // Run it
        return $this->sendRequest($url, $params);
    }
1304382
public function execute()
    {
        $pipeline = array_reduce(
            array_reverse($this->pipes), $this->carry(), function ($passable) {
            return $passable;
        }
        );

        return $pipeline($this->passable);
    }
352063
public function exec(): int
    {

        $output = [];
        $currentDir = getcwd();
        $returnValue = -1;

        $command = $currentDir . "/bin/box.phar compile";

        exec($command, $output, $returnValue);

        if ($returnValue != 0) {
            throw new \Exception("Error while generating phar: $returnValue");
        }

        return $returnValue;

    }
740008
public function execute()
	{
		putenv('LINES=' . $this->terminal->getHeight());
		putenv('COLUMNS=' . $this->terminal->getWidth());

		$this->configureIO();

		try
		{
			$this->dispatchEvent(ApplicationEvents::BEFORE_EXECUTE);

			// Perform application routines.
			$exitCode = $this->doExecute();

			$this->dispatchEvent(ApplicationEvents::AFTER_EXECUTE);
		}
		catch (\Throwable $throwable)
		{
			if (!$this->shouldCatchThrowables())
			{
				throw $throwable;
			}

			$event = new ApplicationErrorEvent($throwable, $this, $this->runningCommand);

			$this->dispatchEvent(ConsoleEvents::APPLICATION_ERROR, $event);

			$exitCode = $event->getExitCode();

			if (is_numeric($exitCode))
			{
				$exitCode = (int) $exitCode;

				if ($exitCode === 0)
				{
					$exitCode = 1;
				}
			}
			else
			{
				$exitCode = 1;
			}
		}
		finally
		{
			if ($this->shouldAutoExit() && isset($exitCode))
			{
				$exitCode = $exitCode > 255 ? 255 : $exitCode;
				$this->close($exitCode);
			}
		}
	}
1038029
public function execute()
    {
        $output = [];
        $code = 0;

        exec(sprintf($this->command, $this->hgPath, $this) . " 2>&1", $output, $code);

        if ($code != 0) {
            throw new \RuntimeException(
                'An error occurred while using VersionControl_HG; hg returned: '
                . implode(PHP_EOL, $output),
                $code
            );
        }

        return implode(PHP_EOL, $output);
    }
849876
public function execute()
    {
        $stmt = $this->connection->prepare($this->getSQL());
        $stmt->execute($this->getParams());

        return $this->counting ? (int) $stmt->fetchColumn() : $stmt->fetchAll();
    }
783666
private function execute()
    {
        $data = curl_exec($this->ch);

        if ($data === false) {
            $this->close();

            throw new \Exception('Impossible to pass the result.');
        }

        $this->error = curl_error($this->ch);

        $this->errno = curl_errno($this->ch);

        $this->header = curl_getinfo($this->ch);

        $this->executed = true;

        $this->close();

        return $data;
    }
1201095
public function execute()
    {

        $message = $this->phpci->interpolate($this->message);
        $successfulBuild = $this->build->isSuccessful() ? 'Success' : 'Failed';
        $push = new Push($this->api_key);
        $flowMessage = TeamInboxMessage::create()
            ->setSource("PHPCI")
            ->setFromAddress($this->email)
            ->setFromName($this->build->getProject()->getTitle())
            ->setSubject($successfulBuild)
            ->setTags(['#ci'])
            ->setLink($this->build->getBranchLink())
            ->setContent($message);

        if (!$push->sendTeamInboxMessage($flowMessage, array('connect_timeout' => 5000, 'timeout' => 5000))) {
            throw new \Exception(sprintf('Flowdock Failed: %s', $flowMessage->getResponseErrors()));
        }
        return true;
    }
869499
public function execute()
    {
        $curdir = getcwd();
        chdir($this->workingdir);

        $phpcsfixer = $this->phpci->findBinary('php-cs-fixer');

        $cmd = $phpcsfixer . ' fix . %s %s %s';
        $success = $this->phpci->executeCommand($cmd, $this->verbose, $this->diff, $this->level);

        chdir($curdir);

        return $success;
    }
1177259
public function perform()
    {
        $app = $this->application();

        $command = $this->getConsoleCommand($app);

        $inputDefinition = $this->getInputDefinition($this->args);

        // Create Input object with $this->args loaded as Input arguments
        $input  = new ArrayInput($this->args, $inputDefinition);
        $output = new ConsoleOutput;

        // Output error details to the console if available
        try {
            $command->run($input, $output);
        } catch (\Exception $e) {
            $output->writeln('Exception: '.$e->getMessage());
            $output->writeln('Code: '.$e->getCode());
            $output->writeln('Stack trace: '.$e->getTraceAsString());

            throw $e;
        }
    }
381765
public function handle()
    {
        $index = $this->index();

        // Checks if the target index exists
        if (!$this->existsStatement($index)) {
            $this->error('Index « '.$index.' » does not exists.');

            return;
        }

        // Runs the mappings
        if ($this->option('mappings')) {
            $this->call('mapping:rerun', [
                '--index'    => $index,
                '--database' => $this->option('database'),
                '--force'    => true,
            ]);
        }

        // Populates the index
        try {
            $this->populateIndex($index);
        } catch (\Exception $e) {
            $this->warn('An error occured while populating the new index !');

            throw $e;
        }
    }
1239565
public function handle()
    {
        $roleName = $this->argument('role');

        if (! $role = Role::whereName($roleName)->first()) {
            $this->warn("Role {$roleName} not exists.");
            return 1;
        }

        $attachList = array_merge($this->option('id'), $this->option('name'));

        $role->detachPermission($attachList);
        echo "Detached permissions. Done!", PHP_EOL;

        return 0;
    }