public function getArguments() {
return array(
'current' => array(
- 'help' => 'Current term in the argument list being completed.',
'param' => 'cursor_position',
+ 'paramtype' => 'int',
+ 'help' => 'Current term in the argument list being completed.',
),
'*' => 'argv',
);
}
public function run() {
-
$pos = $this->getArgument('current');
$argv = $this->getArgument('argv', array());
$argc = count($argv);
$pos = $argc - 1;
}
+ if ($pos > $argc) {
+ throw new ArcanistUsageException(
+ 'Specified position is greater than the number of arguments provided.');
+ }
+
// Determine which revision control system the working copy uses, so we
// can filter out commands and flags which aren't supported. If we can't
// figure it out, just return all flags/commands.
$arc_config = $this->getArcanistConfiguration();
- if ($pos == 1) {
+ if ($pos <= 1) {
$workflows = $arc_config->buildAllWorkflows();
$complete = array();
$supported = $workflow->getSupportedRevisionControlSystems();
- $ok = (in_array('any', $supported)) ||
- (in_array($vcs, $supported));
+ $ok = (in_array('any', $supported) || in_array($vcs, $supported));
if (!$ok) {
continue;
}
}
return 0;
} else {
-
$output = array();
foreach ($arguments as $argument => $spec) {
if ($argument == '*') {
$branches = ipull($branches, 'name');
$output = $branches;
} else {
- $output = array("FILE");
+ $output = array('FILE');
}
}