nategood / commando

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

getValue() not working #75

Open jameswithers opened 7 years ago

jameswithers commented 7 years ago

echo $command['n] successfully returns what's passed as -n, but $command->getOption('n')->getValue() returns nothing

agmckee commented 7 years ago

I also ran into this issue.

NeoVance commented 6 years ago

You must run the parse function to parse the args before you can get an options value. It happens that the array access function automatically runs the parse function.

Parsing the arguments can be an expensive operation depending on the command, and the options being used. It is designed to execute lazily, and only once.

use isParsed to find out if the arguments have been parsed. The option value will not be set yet if it returns false.