mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 08:42:40 +01:00
Improve handling of options for arc
workflows
Summary: Allow `--severity=warning` to mean the same as `--severity warning`. Longer term, we should convert this code to use `PhutilArgumentParser`, although it doesn't seem that `PhutilArgumentParser` support British spelling ;) Test Plan: Ran `arc lint --severity=warning`. Also `var_dump`ed `$args` to make sure it looked reasonable. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11464
This commit is contained in:
parent
1cc8f3f377
commit
937861ce58
1 changed files with 11 additions and 2 deletions
|
@ -661,7 +661,8 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
$more = array();
|
$more = array();
|
||||||
for ($ii = 0; $ii < count($args); $ii++) {
|
$size = count($args);
|
||||||
|
for ($ii = 0; $ii < $size; $ii++) {
|
||||||
$arg = $args[$ii];
|
$arg = $args[$ii];
|
||||||
$arg_name = null;
|
$arg_name = null;
|
||||||
$arg_key = null;
|
$arg_key = null;
|
||||||
|
@ -672,6 +673,14 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
break;
|
break;
|
||||||
} else if (!strncmp($arg, '--', 2)) {
|
} else if (!strncmp($arg, '--', 2)) {
|
||||||
$arg_key = substr($arg, 2);
|
$arg_key = substr($arg, 2);
|
||||||
|
$parts = explode('=', $arg_key, 2);
|
||||||
|
if (count($parts) == 2) {
|
||||||
|
list($arg_key, $val) = $parts;
|
||||||
|
|
||||||
|
array_splice($args, $ii, 1, array('--'.$arg_key, $val));
|
||||||
|
$size++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!array_key_exists($arg_key, $spec)) {
|
if (!array_key_exists($arg_key, $spec)) {
|
||||||
$corrected = ArcanistConfiguration::correctArgumentSpelling(
|
$corrected = ArcanistConfiguration::correctArgumentSpelling(
|
||||||
$arg_key,
|
$arg_key,
|
||||||
|
@ -706,7 +715,7 @@ abstract class ArcanistWorkflow extends Phobject {
|
||||||
if (empty($options['param'])) {
|
if (empty($options['param'])) {
|
||||||
$dict[$arg_key] = true;
|
$dict[$arg_key] = true;
|
||||||
} else {
|
} else {
|
||||||
if ($ii == count($args) - 1) {
|
if ($ii == $size - 1) {
|
||||||
throw new ArcanistUsageException(pht(
|
throw new ArcanistUsageException(pht(
|
||||||
"Option '%s' requires a parameter.",
|
"Option '%s' requires a parameter.",
|
||||||
$arg));
|
$arg));
|
||||||
|
|
Loading…
Reference in a new issue