From a9adf7b78bcefe3b5db03e167f53c6263dab1549 Mon Sep 17 00:00:00 2001 From: smhmic Date: Tue, 10 Sep 2013 15:29:23 -0400 Subject: [PATCH] allow (but ignore) a leading "[no-]" before flag name in @synopsis `no-` prefix on flag name sets it to `false`, but there was no valid way to show this in usage synopsis. Showing this is relevant for flags with a dynamic default value (like `--color` config flag). This change makes `@synopsis [--[no-]flag]` valid. --- php/WP_CLI/SynopsisParser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/WP_CLI/SynopsisParser.php b/php/WP_CLI/SynopsisParser.php index 1da1504e..37cc3aca 100644 --- a/php/WP_CLI/SynopsisParser.php +++ b/php/WP_CLI/SynopsisParser.php @@ -44,7 +44,7 @@ class SynopsisParser { $param['type'] = 'generic'; } elseif ( preg_match( "/^<$p_value>$/", $token, $matches ) ) { $param['type'] = 'positional'; - } elseif ( preg_match( "/^--$p_name/", $token, $matches ) ) { + } elseif ( preg_match( "/^--(?:\\[no-\\])?$p_name/", $token, $matches ) ) { $param['name'] = $matches[1]; $value = substr( $token, strlen( $matches[0] ) ); -- 2.11.0