From 7bd41b7880f70c9deca692d6ea446e74a8e4b8f9 Mon Sep 17 00:00:00 2001 From: jmslbam Date: Thu, 1 Aug 2013 23:12:55 +0200 Subject: [PATCH] Exclude assoc args with that have an optional value from being unset An assoc args with an option value shouldn't trigger the message "--foo parameter needs a value". Because it doesn't needs a value. Else it would defeat the whole purpose of having `--foo[=]`. It needs to be available within the command so you can still do something with it. --- php/WP_CLI/SynopsisValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/WP_CLI/SynopsisValidator.php b/php/WP_CLI/SynopsisValidator.php index 90a7cb87..bee3f192 100644 --- a/php/WP_CLI/SynopsisValidator.php +++ b/php/WP_CLI/SynopsisValidator.php @@ -50,7 +50,7 @@ class SynopsisValidator { $errors['fatal'][] = "missing --$key parameter"; } } else { - if ( true === $assoc_args[ $key ] ) { + if ( true === $assoc_args[ $key ] && !$param['value']['optional'] ) { $error_type = ( !$param['optional'] ) ? 'fatal' : 'warning'; $errors[ $error_type ][] = "--$key parameter needs a value"; -- 2.11.0