nategood / commando

An Elegant CLI Library for PHP
MIT License
798 stars 80 forks source link

Get all remaining items #99

Closed staff0rd closed 5 years ago

staff0rd commented 5 years ago

If i've configured argument parsing for x and y, in scenarios below what is the best way to retrieve all tokens after the last parsed argument?

script.php -x arg1 -y arg2 everything else that's here
script.php -x arg1 everything else that's here

I can achieve a variable containing everything else that's here but only if I enclose it in quotes. Any way to do this without quotes?

tolidano commented 5 years ago

I imagine the getArguments() method will work.

Parse has this snippet:

if ($type === self::OPTION_TYPE_ARGUMENT) {
                    // it is an argument, use an int as the index
                    $keyvals[$count] = $name;

                    // We allow for "dynamic" anonymous arguments, so we
                    // add an option for any anonymous arguments that
                    // weren't predefined
                    if (!$this->hasOption($count)) {
                        $this->options[$count] = new Option($count);
                    }

                    $count++;
                } else {
nategood commented 5 years ago

Can iterate through options. Quotes are the usual expected behavior.