nategood / commando

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

Only evaluate 'needs' constraints of an option if that option is actually used. #101

Closed inquam closed 5 years ago

inquam commented 5 years ago

From the way I understood 'needs' it would create constraints that would make sure needed options that another option rely on are set. But the check seems to happen even if you haven't used the option that 'needs' the other options.

I, for instance, created an option to take an SMTP server host name. Then I added options to supply username and password for that server if that was needed for the server. Using those options would 'need' the server address to be present.

But even if I didn't set the SMTP server or any of the username and password options it still complained about the need constraint. This made very little sense.

So I added a small check so it only evaluates 'needs' constraints of an option if that option is actually used.