From 06b2d52c28726581f56eb3b514e0c0e5c22086a9 Mon Sep 17 00:00:00 2001 From: inquam Date: Wed, 3 Jul 2019 07:58:22 +0200 Subject: [PATCH] Update Command.php Only check for 'needs' constraints of an option if that option is actually used --- src/Commando/Command.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Commando/Command.php b/src/Commando/Command.php index 26b494e..993f68b 100755 --- a/src/Commando/Command.php +++ b/src/Commando/Command.php @@ -495,10 +495,11 @@ public function parse() } } - // See if our options have what they require + // See if our options have what they require. + // But only do so if the option is actually used foreach ($this->options as $option) { $needs = $option->hasNeeds($this->options); - if ($needs !== true) { + if ($needs !== true && array_key_exists($option->getName(), $keyvals)) { throw new \InvalidArgumentException( 'Option "' . $option->getName() . '" does not have required option(s): ' . implode(', ', $needs) );