Changeset View
Changeset View
Standalone View
Standalone View
src/toolset/workflow/ArcanistShellCompleteWorkflow.php
Context not available. | |||||
$argv = $this->getArgument('argv'); | $argv = $this->getArgument('argv'); | ||||
$is_generate = $this->getArgument('generate'); | $is_generate = $this->getArgument('generate'); | ||||
$is_shell = (bool)strlen($this->getArgument('shell')); | $is_shell = (bool)@strlen($this->getArgument('shell')); | ||||
$is_current = $this->getArgument('current'); | $is_current = $this->getArgument('current'); | ||||
if ($argv) { | if ($argv) { | ||||
Context not available. | |||||
$file = $spec['file']; | $file = $spec['file']; | ||||
$home = getenv('HOME'); | $home = getenv('HOME'); | ||||
if (!strlen($home)) { | if (!@strlen($home)) { | ||||
throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
pht( | pht( | ||||
'The "HOME" environment variable is not defined, so this workflow '. | 'The "HOME" environment variable is not defined, so this workflow '. | ||||
Context not available. | |||||
$this->getShellPath($spec['source'])); | $this->getShellPath($spec['source'])); | ||||
$matches = null; | $matches = null; | ||||
$replace = preg_match( | $replace = @preg_match( | ||||
'/(\s*\n)?[^\n]+# arcanist-shell-complete\s*(\n\s*)?/', | '/(\s*\n)?[^\n]+# arcanist-shell-complete\s*(\n\s*)?/', | ||||
$data, | $data, | ||||
$matches, | $matches, | ||||
Context not available. | |||||
if ($replace) { | if ($replace) { | ||||
$replace_pos = $matches[0][1]; | $replace_pos = $matches[0][1]; | ||||
$replace_line = $matches[0][0]; | $replace_line = $matches[0][0]; | ||||
$replace_len = strlen($replace_line); | $replace_len = @strlen($replace_line); | ||||
$replace_display = trim($replace_line); | $replace_display = trim($replace_line); | ||||
if ($replace_pos === 0) { | if ($replace_pos === 0) { | ||||
Context not available. | |||||
pht('Detecting current shell...')); | pht('Detecting current shell...')); | ||||
$shell_env = getenv('SHELL'); | $shell_env = getenv('SHELL'); | ||||
if (!strlen($shell_env)) { | if (!@strlen($shell_env)) { | ||||
$log->writeWarning( | $log->writeWarning( | ||||
pht('SHELL'), | pht('SHELL'), | ||||
pht( | pht( | ||||
Context not available. | |||||
$argument = null; | $argument = null; | ||||
$prev = idx($argv, $pos - 1, null); | $prev = idx($argv, $pos - 1, null); | ||||
if (!strncmp($prev, '--', 2)) { | if (!strncmp($prev, '--', 2)) { | ||||
$prev = substr($prev, 2); | $prev = @substr($prev, 2); | ||||
$argument = idx($arguments, $prev); | $argument = idx($arguments, $prev); | ||||
} | } | ||||
Context not available. | |||||
// a parameterized argument. If it is, the next argument should be a | // a parameterized argument. If it is, the next argument should be a | ||||
// parameter. | // parameter. | ||||
if ($argument && strlen($argument->getParameter())) { | if ($argument && @strlen($argument->getParameter())) { | ||||
if ($argument->getIsPathArgument()) { | if ($argument->getIsPathArgument()) { | ||||
return $this->suggestPaths($current); | return $this->suggestPaths($current); | ||||
} else { | } else { | ||||
Context not available. | |||||
// READ<tab>" should autocomplete a file, and "arc lint <tab>" should | // READ<tab>" should autocomplete a file, and "arc lint <tab>" should | ||||
// suggest files in the current directory. | // suggest files in the current directory. | ||||
if (!strlen($current) || !$matches) { | if (!@strlen($current) || !$matches) { | ||||
$try_paths = true; | $try_paths = true; | ||||
} else { | } else { | ||||
$try_paths = false; | $try_paths = false; | ||||
Context not available. | |||||
private function getMatches(array $candidates, $prefix) { | private function getMatches(array $candidates, $prefix) { | ||||
$matches = array(); | $matches = array(); | ||||
if (strlen($prefix)) { | if (@strlen($prefix)) { | ||||
foreach ($candidates as $possible) { | foreach ($candidates as $possible) { | ||||
if (!strncmp($possible, $prefix, strlen($prefix))) { | if (!strncmp($possible, $prefix, @strlen($prefix))) { | ||||
$matches[] = $possible; | $matches[] = $possible; | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
// If we matched nothing, try a case-insensitive match. | // If we matched nothing, try a case-insensitive match. | ||||
if (!$matches) { | if (!$matches) { | ||||
foreach ($candidates as $possible) { | foreach ($candidates as $possible) { | ||||
if (!strncasecmp($possible, $prefix, strlen($prefix))) { | if (!strncasecmp($possible, $prefix, @strlen($prefix))) { | ||||
$matches[] = $possible; | $matches[] = $possible; | ||||
} | } | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0