Skip to content

Commit

Permalink
Allow short options. Needed to pass along -vvv
Browse files Browse the repository at this point in the history
--verbose=3 is not allowed by its InputDefinition. --verbose does not accept a value (i.e. is VALUE_NONE). It must be passed as short option.

So we enable convertOptions() to pass along short options via a magic value `-short`. Magic values of true and false are already supported so hopefully this doesnt smell too bad.

This enables a fix for drush-ops/drush#5909
  • Loading branch information
weitzman committed Mar 30, 2024
1 parent 6c44638 commit c527fbd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Util/ArgumentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ protected function convertOptions($options)
foreach ($options as $option => $value) {
if ($value === true || $value === null) {
$result[] = "--$option";
} elseif ($value === '-short') {
$result[] = "-$option";
} elseif ($value === false) {
// Ignore this option.
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/ArgumentProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public function argumentProcessorTestValues()
],

[
'["drush", "status", "--fields=root,uri"]',
'["drush", "status", "-vvv", "--fields=root,uri"]',
[],
['drush', 'status'],
['fields' => 'root,uri'],
['vvv' => '-short', 'fields' => 'root,uri'],
[],
],

Expand Down

0 comments on commit c527fbd

Please sign in to comment.