Gets a clean command-line arguments and options.

@return object
497249
protected function getCommandInput()
    {
        $modelName = trim($this->argument('model-name'));
        $cName = trim($this->option('controller-name'));
        $controllerName = $cName ? str_finish($cName, Config::getControllerNamePostFix()) : Helpers::makeControllerName($modelName);
        $viewDirectory = $this->option('views-directory');
        $prefix = ($this->option('routes-prefix') == 'default-form') ? Helpers::makeRouteGroup($modelName) : $this->option('routes-prefix');
        $perPage = intval($this->option('models-per-page'));
        $resourceFile = trim($this->option('resource-file')) ?: Helpers::makeJsonFileName($modelName);
        $langFile = $this->option('language-filename') ?: Helpers::makeLocaleGroup($modelName);
        $withFormRequest = $this->option('with-form-request');
        $force = $this->option('force');
        $modelDirectory = $this->option('model-directory');
        $controllerDirectory = trim($this->option('controller-directory'));
        $formRequestName = Helpers::makeFormRequestName($modelName);
        $template = $this->getTemplateName();
        $formRequestDirectory = trim($this->option('form-request-directory'));
        $extends = $this->generatorOption('controller-extends');
        $withAuth = $this->option('with-auth');

        return (object) compact(
            'formRequestDirectory',
            'viewDirectory',
            'modelName',
            'prefix',
            'perPage',
            'modelDirectory',
            'langFile',
            'withFormRequest',
            'formRequestName',
            'force',
            'resourceFile',
            'template',
            'controllerName',
            'extends',
            'withAuth',
            'controllerDirectory'
        );
    }
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
        ]);
    }
498128
public static function getArgumentSpecifications()
    {
        $specs = new OptionCollection;
        $specs->add('d|dir:', 'Tests directory path')
            ->isa('String');

        $specs->add('s|subdir+', 'Optional, subdirectory pattern, can be used multiple times as OR expression')
            ->isa('String')
            ->defaultValue(null);

        $specs->add('b|bootstrap?', 'Bootstrap file path')
            ->isa('File')
            ->defaultValue(null);

        $specs->add('v|verbose', 'Verbose output')
            ->defaultValue(false);

        $specs->add('show-globals', 'Show values of global variables')->defaultValue(false);
        $specs->add('debug', 'Show debug messages')->defaultValue(false);
        $specs->add('h|help', 'Show help')->defaultValue(false);
        $specs->add('no-colors', 'No colors')->defaultValue(false);
        $specs->add('i|immediate', 'Show error output immediately as it appears')->defaultValue(false);

        $specs->add('server-host?', 'Server host')->defaultValue(null);
        $specs->add('server-root',  'Server root path, default is ./public')->defaultValue('./public');

        return $specs;
    }
775692
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        $parser->setDescription(
            'Used by shells like bash to autocomplete command name, options and arguments'
        )->addSubcommand('commands', [
            'help' => 'Output a list of available commands',
            'parser' => [
                'description' => 'List all available',
            ]
        ])->addSubcommand('subcommands', [
            'help' => 'Output a list of available subcommands',
            'parser' => [
                'description' => 'List subcommands for a command',
                'arguments' => [
                    'command' => [
                        'help' => 'The command name',
                        'required' => false,
                    ]
                ]
            ]
        ])->addSubcommand('options', [
            'help' => 'Output a list of available options',
            'parser' => [
                'description' => 'List options',
                'arguments' => [
                    'command' => [
                        'help' => 'The command name',
                        'required' => false,
                    ],
                    'subcommand' => [
                        'help' => 'The subcommand name',
                        'required' => false,
                    ]
                ]
            ]
        ])->addSubcommand('fuzzy', [
            'help' => 'Guess autocomplete'
        ])->setEpilog([
            'This command is not intended to be called manually',
        ]);

        return $parser;
    }
621459
protected function getDefaultCommands()
  {
    // Keep the core default commands to have the HelpCommand which is used when using the --help option
    $defaultCommands = parent::getDefaultCommands();

    $defaultCommands[] = new ConstantsCommand();
    $defaultCommands[] = new CrudCommand();
    $defaultCommands[] = new NonStaticCommand();
    $defaultCommands[] = new RoutineLoaderCommand();
    $defaultCommands[] = new RoutineWrapperGeneratorCommand();
    $defaultCommands[] = new StratumCommand();

    return $defaultCommands;
  }
1049751
public function parse()
    {
        $input = new ArgvInput($this->arguments);
        $parsed = [];

        foreach ($this->search as $option) {
            if ($input->hasParameterOption($option)) {
                $name = ltrim($option, '-');
                $parsed[$name] = $input->getParameterOption($option);
            }
        }

        return $parsed;
    }
874238
public function getOptionsForConsole()
    {
        $builder = '';

        foreach ($this->options as $option => $value) {
            $builder .= '--' . $option;

            if ($value) {
                $builder .= '=' . $value;
            }

            $builder .= ' ';
        }

        return $builder;
    }
529722
public function getAllCommandPrototype()
    {
        $lines = [];

        if (method_exists($this, 'execute')) {
            $lines[] = $this->getCommandPrototype();
        }

        if ($this->hasCommands()) {
            foreach ($this->commands as $name => $subcmd) {
                $lines[] = $subcmd->getCommandPrototype();
            }
        }

        return $lines;
    }
41137
public function getParams()
    {
        if ($this->cachedParams) {
            return $this->cachedParams;
        }

        $CMDS = [];
        $KEYS = [];
        $ARGV = [];
        $KEYNUM = 0;
        $ARGNUM = 0;

        foreach ($this->stack as $part) {
            list($cmd, $keys, $argv) = $part;

            if (!empty($keys)) {
                $cmd = preg_replace_callback('~KEYS\[(\d+)\]~', function ($m) use (&$KEYS, &$KEYNUM, $keys) {
                    $key = $keys[$m[1] - 1];
                    if (!isset($KEYS[$key])) {
                        $KEYS[$key] = ++$KEYNUM;
                    }
                    return 'KEYS[' . $KEYS[$key] . ']';
                }, $cmd);
            }

            if (!empty($argv)) {
                $cmd = preg_replace_callback('~ARGV\[(\d+)\]~', function ($m) use (&$ARGV, &$ARGNUM, $argv) {
                    $arg = $argv[$m[1] - 1];
                    if (!isset($ARGV[$arg])) {
                        $ARGV[$arg] = ++$ARGNUM;
                    }
                    return 'ARGV[' . $ARGV[$arg] . ']';
                }, $cmd);
            }

            $CMDS[] = $cmd;
        }

        return $this->cachedParams = array_merge(
            [implode(';', $CMDS), count($KEYS)],
            array_keys($KEYS),
            array_keys($ARGV)
        );
    }
583828
static public function cli()
	{
	    $key = 'app.cli';
	    
	    if (!static::has($key)) {
	        if ( !($app = static::app()) || !$app->isCli()) {
	            static::setShared($key, new \Wslim\Console\App(Config::getCliAppPath()));
	        }
	    }
	    
	    return static::get($key);
	}
791047
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        $parser->addOption('cli', [
                'help' => 'Use the bootstrap_cli file.',
                'boolean' => true,
                'default' => false,
            ])
            ->addOption('no_app', [
                'help' => 'Do not update the Application if it exist. Forces config/bootstrap.php to be updated.',
                'boolean' => true,
                'default' => false,
            ])
            ->addArgument('plugin', [
                'help' => 'Name of the plugin to load.',
            ]);

        return $parser;
    }
678941
public function args()
    {
        $existing = is_callable($this->args) ? call_user_func($this->args) : $this->args;

        if (!is_array($existing)) {
            $existing = [];
        }

        $args = array_merge($existing, [
            'limit' => [
                'type' => Type::int(),
            ],
            'offset' => [
                'type' => Type::int()
            ]
        ]);

        if ($fields = $this->getSortableFields()) {
            $args['sortBy'] = [
                'type' => Type::listOf(
                    Injector::inst()->create(SortInputTypeCreator::class, $this->connectionName)
                        ->setSortableFields($fields)
                        ->toType()
                )
            ];
        }

        return $args;
    }
245645
private function getopt()
    {

        // Reset option argument
        $this->optarg = null;
        
        // Check for index validity
        if ($this->optind >= $this->argc) {
            return -1;
        }

        // Get a copy of the current option to examine
        $arg = $this->argv[$this->optind];

        if ($this->isLongOption($arg)) {
            return $this->parseLongOption($arg);
        }

        if ($this->isShortOption($arg)) {
            return $this->parseShortOption($arg);
        }

        // If it's not an option, it's an argument,
        // so we stop parsing at the first non-option string
        // and $this->optind points to the first argument

        // Default: no options found
        return -1;
    }
1225953
protected function getCommandInput()
    {
        $modelName = trim($this->argument('model-name'));
        $fileName = trim($this->option('language-filename')) ?: Helpers::makeLocaleGroup($modelName);
        $resourceFile = trim($this->option('resource-file')) ?: Helpers::makeJsonFileName($modelName);
        $template = trim($this->option('template-name'));

        return (object) compact(
            'modelName',
            'fileName',
            'resourceFile',
            'template'
        );
    }
254571
public function commands()
    {
        $shellList = $this->getShellList();
        $flatten = Hash::flatten($shellList);
        $duplicates = array_intersect($flatten, array_unique(array_diff_key($flatten, array_unique($flatten))));
        $duplicates = Hash::expand($duplicates);

        $options = [];
        foreach ($shellList as $type => $commands) {
            foreach ($commands as $shell) {
                $prefix = '';
                if (!in_array(strtolower($type), ['app', 'core']) &&
                    isset($duplicates[$type]) &&
                    in_array($shell, $duplicates[$type])
                ) {
                    $prefix = $type . '.';
                }

                $options[] = $prefix . $shell;
            }
        }

        return $options;
    }
916575
public function getUsage()
    {
        $string = [];

        $string[] = $this->getName();

        foreach ($this->getArguments() as $argument) {
            if ($argument->isRequired()) {
                $string[] = $argument->getName();
            } else {
                $string[] = "[{$argument->getName()}]";
            }
        }

        foreach ($this->getOptions() as $option) {
            $dashes = '-';
            if (!$option->isFlagOption()) {
                $dashes .= '-';
            }
            if ($option->isValueRequired()) {
                $optionString = "{$option->getName()}=value";
            } else {
                $optionString = "{$option->getName()}[=value]";
            }
            $string[] = "[{$dashes}{$optionString}]";
        }

        return implode(' ', $string);
    }
880579
private function getProcessCommand()
    {
        $options   = $this->transformOptions();
        $options[] = escapeshellarg($this->input);

        $command = $this->binary . ' ' . implode(' ', $options);

        return $command;
    }