nategood / commando

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

Setting an option value via array syntax is not permitted #110

Closed boooyu44 closed 4 years ago

boooyu44 commented 4 years ago

Hi

Why is setting values not permitted? I want to use a "--dry" flag that will automatically activate few other options via boolean flags, so the user doesn't have to type 3 switches but just to use one.

$command= new Commando\Command();

// some options are defined here

//--dry flag should enable --skip --run --show flags
if ($command['dry']) {
    $command['skip'] = true;
    $command['run'] = true;
    $command['show'] = true;
}
Fatal error: Uncaught Exception: Setting an option value via array syntax is not permitted in C:\......1
Stack trace:

Is there any workaround? Like get a copy of parsed options as array and then overrwrite?

boooyu44 commented 4 years ago

Found solution

$command->getOption('skip')->setValue(true); $command->getOption('run')->setValue(true); $command->getOption('show')->setValue(true);