You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update startup and options to use Cake 3's OptionParser correctly.
The new OptionParser doesn't incorrectly grab arguments after boolean options anymore, but it also doesn't easily permit a variable number of arguments and still allow you to generate help output for them.
Code and tests updated to match the new reality of field use.
@@ -218,29 +207,24 @@ protected function printVal($key, $val) {
218
207
publicfunctiongetOptionParser() {
219
208
$parser = parent::getOptionParser();
220
209
$parser
221
-
->addArgument('key', array(
222
-
'help' => 'The Key.name to fetch from Configure::read().',
223
-
'required' => true,
224
-
))
225
-
->addArgument('key2', array(
226
-
'help' => 'Multiple keys may be specified, separated by spaces.',
227
-
'required' => false,
228
-
))
229
-
->addOption('bash', array(
210
+
->addOption('bash', [
230
211
'short' => 'b',
231
212
'boolean' => true,
232
213
'default' => false,
233
214
'help' => __('Always use bash variable deinfition formatting. When enabled, output will be formatted as `KEY_NAME=\'value\'`. This option is auto-enabled if multiple keys are provided on the command line, or if the value for the requested key is itself an array. When multiple values are returned, each will be output on its own line.')
234
-
))
235
-
->addOption('serialize', array(
215
+
])
216
+
->addOption('serialize', [
236
217
'short' => 's',
237
218
'boolean' => true,
238
219
'default' => false,
239
-
'help' => __('Encode all output using PHP\'s `serialize()` method. Makes the Shell\'s output suitable for consumption by other PHP console scripts. Always overrides the --bash option. A single requested key will be serialized directly. Multiple requested keys will be combined into an associative array and then serialized.')
240
-
))
241
-
->description(__('Provides CLI access to variables defined in the Configure class of the host
242
-
CakePHP application. Will output the value of any keys passed as arguments.
243
-
Equivelant to `Configure::read(\'Key.Name\')`.'));
220
+
'help' => __('Encode all output using PHP\'s `serialize()` method. Makes the Shell\'s output suitable for consumption by other PHP console scripts. Always overrides the --bash option. A single requested key will be serialized directly. Multiple requested keys will be combined into an associative array with the provided arguments as key names and then serialized.')
221
+
])
222
+
->description(
223
+
__('Provides CLI access to variables defined in the Configure class of the host CakePHP application. Will output the value of any keys passed as arguments. Equivelant to `Configure::read(\'Key.Name\')`. Unrecognized keys will produce empty string or `null` output.')
224
+
)
225
+
->epilog(
226
+
__('Provide the Key.name(s) to fetch from Configure::read() as arguments. Multiple keys may be specified, separated by spaces.')
0 commit comments