Parse an argument/option description.

@return $this
166432
protected function setDescription()
    {
        if (strpos($this->input, ':') !== false) {
            $inputArray = array_map('trim', explode(':', $this->input));

            $this->input = $inputArray[0];

            $this->description = $inputArray[1];
        }

        return $this;
    }
360753
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        return $parser->setDescription([
            'Asset Compress Shell',
            '',
            'Builds and clears assets defined in your asset_compress.ini',
            'file and in your view files.'
        ])->addSubcommand('clear', [
            'help' => 'Clears all builds defined in the ini file.'
        ])->addSubcommand('build', [
            'help' => 'Generate all builds defined in the ini files.'
        ])->addOption('force', [
            'help' => 'Force assets to rebuild. Ignores timestamp rules.',
            'short' => 'f',
            'boolean' => true
        ]);
    }
719841
public static function parseCommand()
    {
        global $argv;
        foreach($argv as $file)
        {
            $ext = pathinfo($file, PATHINFO_EXTENSION );
            if($ext !== 'php')
            {
                continue;
            }
            if(is_file($file))
            {
                static::$_startFiles[$file] = $file;
                include_once $file;
            }
        }
    }
175750
public function getArgumentValues()
    {
        $this->parseIfNotParsed();
        return array_map(function(Option $argument) {
            return $argument->getValue();
        }, $this->arguments);
    }
471299
protected function parse()
    {
        $parseOptions = true;
        $this->parsed = $this->tokenPairs;
        while (null !== $tokenPair = \array_shift($this->parsed)) {
            // token is what you'd expect. rest is the remainder of the input
            // string, including token, and will be used if this is a code arg.
            list($token, $rest) = $tokenPair;

            if ($parseOptions && '' === $token) {
                $this->parseShellArgument($token, $rest);
            } elseif ($parseOptions && '--' === $token) {
                $parseOptions = false;
            } elseif ($parseOptions && 0 === \strpos($token, '--')) {
                $this->parseLongOption($token);
            } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
                $this->parseShortOption($token);
            } else {
                $this->parseShellArgument($token, $rest);
            }
        }
    }
1078677
public function getOptionParser()
    {
        $parser = parent::getOptionParser();
        $parser->setDescription('Bakes Module bootstrap configuration files and MVC classes');
        $parser->addArgument('name', [
            'help' => 'The Module name to bake',
            'required' => true
        ]);

        return $parser;
    }
111718
protected function parseCommandAndConfig()
    {
        $this->parseCliOptions();

        $command = $this->command;
        $supported = ['start', 'stop', 'restart', 'reload', 'status'];

        if (!\in_array($command, $supported, true)) {
            $this->showHelp("The command [{$command}] is don't supported!");
        }

        // load CLI Options
        $this->loadCliOptions($this->cliOpts);

        // init Config And Properties
        $this->initConfigAndProperties($this->config);

        // Debug option to dump the config and exit
        if (isset($this->cliOpts['D'])) {
            $val = $this->cliOpts['D'];
            $this->dumpInfo($val === 'all');
        } elseif (isset($this->cliOpts['dump'])) {
            $val = $this->cliOpts['dump'];
            $this->dumpInfo($val === 'all');
        }
    }
826257
public function getOptionParser()
    {
        $parser = parent::getOptionParser();
        $parser->addSubcommand('clear', [
            'help' => 'Clear all metadata caches for the connection. If a ' .
                'table name is provided, only that table will be removed.',
        ])->addSubcommand('build', [
            'help' => 'Build all metadata caches for the connection. If a ' .
            'table name is provided, only that table will be cached.',
        ])->addOption('connection', [
            'help' => 'The connection to build/clear metadata cache data for.',
            'short' => 'c',
            'default' => 'default',
        ])->addArgument('name', [
            'help' => 'A specific table you want to clear/refresh cached data for.',
            'optional' => true,
        ]);

        return $parser;
    }
626746
public function configure()
    {
        switch (count($options = func_get_args())) {
            case 0:
                break;

            case 1:
                $this->configureInstance($options[0]);
                break;

            case 2:
                $this->configureInstanceAssoc(
                    static::authorize($options[0], $options[1])
                );
                break;

            default:
                throw new \InvalidArgumentException('invalid argument count');
                break;
        }

        return $this;
    }
1263351
public function getDescription()
    {
        if (is_string($this->str_description)) {
            $description = new S($this->str_description);

            return $description->wrap(OptionItem::getWidth());
        } else {
            return null;
        }
    }
969482
protected function configureRequiredArguments()
    {
        parent::configureRequiredArguments()
            ->addOption(
                'prefix-dir',
                'd',
                InputOption::VALUE_REQUIRED,
                'Indicate a directory prefix.',
                '.'
            )
            ->addOption(
                'prefix-ns',
                'a',
                InputOption::VALUE_REQUIRED,
                'Indicate a namespace prefix.',
                ''
            )
        ;

        return $this;
    }
917021
private function parsePathArguments()
    {
        if (null !== $this->arguments) {
            return;
        }

        $arguments = [];
        preg_match('/^' . self::pattern($this->configuredPath) . '/', $this->calledPath, $arguments);
        array_shift($arguments);
        $names  = [];
        $this->arguments = [];
        preg_match_all('/[{][^}]*[}]/', str_replace('/', '\/', $this->configuredPath), $names);
        foreach ($names[0] as $key => $name) {
            if (isset($arguments[$key])) {
                $this->arguments[str_replace(['{', '}'], '', $name)] = $arguments[$key];
            }
        }
    }
567563
private function parse()
    {
        $opts = $this->result->options;
        $commandName = $this->result->command_name;
        $command = null;
        $optionSet = $argumentSet = false;

        // special treatment for -h --help main command options
        if ($opts['help'] === true) {
            $commandName = 'help';
        }

        if ($commandName) {
            $configFile = $this->paths['configs'] . 'commands/' . $commandName . '.yml';
            $command = new Command($configFile);
        }

        // check if any option is set
        // basically check for --version -v --help -h options
        foreach ($opts as $name => $value) {
            if ($value === true) {
                $optionSet = true;
                break;
            }
        }

        // fire up subcommand
        if (isset($command['callback'])) {
            $this->invoke($command['callback'], $command);
        }

        if ($commandName === false && $optionSet === false && $argumentSet === false) {
            $this->parser->outputter->stdout("Type 'phrozn help' for usage.\n");
        }
    }
880043
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        $parser->setDescription('Plugin Shell perform various tasks related to plugin.')
            ->addSubcommand('assets', [
                'help' => 'Symlink / copy plugin assets to app\'s webroot',
                'parser' => $this->Assets->getOptionParser()
            ])
            ->addSubcommand('loaded', [
                'help' => 'Lists all loaded plugins',
                'parser' => $parser,
            ])
            ->addSubcommand('load', [
                'help' => 'Loads a plugin',
                'parser' => $this->Load->getOptionParser(),
            ])
            ->addSubcommand('unload', [
                'help' => 'Unloads a plugin',
                'parser' => $this->Unload->getOptionParser(),
            ]);

        return $parser;
    }
325486
private function parseArguments()
    {
        $args = $_SERVER['argv'];

        // The first argument is the script name, so drop it
        array_shift($args);

        // Loop through each of the arguments
        foreach ($args as $index => $task) {
            if (strpos($task, '-') === 0) {
                // Argument is an option, so we remove it
                unset($args[$index]);

                // If the next argument is the option's value,
                // remove that as well.
                $option = preg_replace('/^[-]{1,2}/', '', $task);
                if (isset($args[$index + 1]) && $args[$index + 1] === $this->options->{$option}) {
                    unset($args[$index + 1]);
                }
                continue;
            }
        }

        return $this->args = $args;
    }
274593
protected function constructArguments()
    {
        $args = [];
        foreach ($this->options as $option => $value) {
            if (is_bool($value)) {
                $args[] = '--' . $option . '=' . ($value ? 'yes' : 'no');
            } elseif (is_array($value)) {
                foreach ($value as $v) {
                    $args[] = '--' . $option . '=' . escapeshellarg($v);
                }
            } else {
                $args[] = '--' . $option . '=' . escapeshellarg($value);
            }
        }

        return implode(' ', $args);
    }
163369
protected function specifyParameters()
    {
        // Identify our options
        foreach ($_SERVER['argv'] as $argument) {

            if (!Str::startsWith($argument, '--'.self::TAG_PREFIX)) {
                continue;
            }

            // Strip past the '='
            $argument = substr($argument, 0, strpos($argument, '='));

            // Add as option, if prefix matches
            $this->tags[]    = substr($argument, strlen(self::TAG_PREFIX));
            $this->options[] = [$argument, null, InputOption::VALUE_REQUIRED];
        }

        return parent::specifyParameters();
    }