mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-21 22:32:41 +01:00
Allow "arc" to accept any prefix of a command as that command
Summary: Ref T13546. Practically, this allows "arc branch" to run "arc branches". (This risks overcorrection to some degree, but command correction only occurs if stdout is a TTY so the risk seems limited.) Test Plan: Ran "arc branch", got "arc branches" as a correction. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21338
This commit is contained in:
parent
31d08f9a8f
commit
e8c3cc3289
1 changed files with 15 additions and 0 deletions
|
@ -115,6 +115,21 @@ final class PhutilArgumentSpellingCorrector extends Phobject {
|
||||||
$options[$key] = $this->normalizeString($option);
|
$options[$key] = $this->normalizeString($option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In command mode, accept any unique prefix of a command as a shorthand
|
||||||
|
// for that command.
|
||||||
|
if ($this->getMode() === self::MODE_COMMANDS) {
|
||||||
|
$prefixes = array();
|
||||||
|
foreach ($options as $option) {
|
||||||
|
if (!strncmp($input, $option, strlen($input))) {
|
||||||
|
$prefixes[] = $option;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($prefixes) === 1) {
|
||||||
|
return $prefixes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$distances = array();
|
$distances = array();
|
||||||
$inputv = phutil_utf8v($input);
|
$inputv = phutil_utf8v($input);
|
||||||
foreach ($options as $option) {
|
foreach ($options as $option) {
|
||||||
|
|
Loading…
Reference in a new issue