diff --git a/src/Util/ArgumentProcessor.php b/src/Util/ArgumentProcessor.php index c83afd9..e6fa2d8 100644 --- a/src/Util/ArgumentProcessor.php +++ b/src/Util/ArgumentProcessor.php @@ -13,6 +13,18 @@ */ class ArgumentProcessor { + private $short_options = ['vv', 'vvv']; + + public function getShortOptions(): array + { + return $this->short_options; + } + + public function setShortOptions(array $short_options): void + { + $this->short_options = $short_options; + } + /** * selectArgs selects the appropriate set of arguments for the command * to be executed and orders them as needed. @@ -81,15 +93,21 @@ protected function convertOptions($options) { $result = []; foreach ($options as $option => $value) { + $dashes = str_repeat('-', $this->dashCount($option)); if ($value === true || $value === null) { - $result[] = "--$option"; + $result[] = $dashes . $option; } elseif ($value === false) { // Ignore this option. } else { - $result[] = "--{$option}={$value}"; + $result[] = "{$dashes}{$option}={$value}"; } } return $result; } + + protected function dashCount($name): int + { + return in_array($name, $this->getShortOptions()) ? 1 : 2; + } } diff --git a/tests/ArgumentProcessorTest.php b/tests/ArgumentProcessorTest.php index e1e6867..f943477 100644 --- a/tests/ArgumentProcessorTest.php +++ b/tests/ArgumentProcessorTest.php @@ -23,10 +23,10 @@ public function argumentProcessorTestValues() ], [ - '["drush", "status", "--fields=root,uri"]', + '["drush", "status", "-vvv", "--fields=root,uri"]', [], ['drush', 'status'], - ['fields' => 'root,uri'], + ['vvv' => TRUE, 'fields' => 'root,uri'], [], ],