mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
Use PhutilArgumentParser for some argument parsing in Arcanist
Summary: Instead of doing custom parsing for --trace and --no-ansi, use builtin parsing. This also gives us access to xprofile. I eventually want to fully switch over, but that'll take some work. Test Plan: Ran `arc list --trace`, `arc list --no-ansi`, etc. Reviewers: btrahan Reviewed By: btrahan CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1827
This commit is contained in:
parent
465ad3fa44
commit
92febf184e
1 changed files with 9 additions and 18 deletions
|
@ -34,20 +34,20 @@ phutil_require_module('arcanist', 'repository/api/base');
|
||||||
|
|
||||||
ini_set('memory_limit', -1);
|
ini_set('memory_limit', -1);
|
||||||
|
|
||||||
$config_trace_mode = false;
|
$original_argv = $argv;
|
||||||
|
$args = new PhutilArgumentParser($argv);
|
||||||
|
$args->parseStandardArguments();
|
||||||
|
|
||||||
|
$argv = $args->getUnconsumedArgumentVector();
|
||||||
|
$config_trace_mode = $args->getArg('trace');
|
||||||
|
|
||||||
$force_conduit = null;
|
$force_conduit = null;
|
||||||
$args = array_slice($argv, 1);
|
$args = $argv;
|
||||||
$load = array();
|
$load = array();
|
||||||
$matches = null;
|
$matches = null;
|
||||||
foreach ($args as $key => $arg) {
|
foreach ($args as $key => $arg) {
|
||||||
if ($arg == '--') {
|
if ($arg == '--') {
|
||||||
break;
|
break;
|
||||||
} else if ($arg == '--trace') {
|
|
||||||
unset($args[$key]);
|
|
||||||
$config_trace_mode = true;
|
|
||||||
} else if ($arg == '--no-ansi') {
|
|
||||||
unset($args[$key]);
|
|
||||||
PhutilConsoleFormatter::disableANSI(true);
|
|
||||||
} else if (preg_match('/^--load-phutil-library=(.*)$/', $arg, $matches)) {
|
} else if (preg_match('/^--load-phutil-library=(.*)$/', $arg, $matches)) {
|
||||||
unset($args[$key]);
|
unset($args[$key]);
|
||||||
$load[] = $matches[1];
|
$load[] = $matches[1];
|
||||||
|
@ -57,20 +57,11 @@ foreach ($args as $key => $arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The POSIX extension is not available by default in some PHP installs.
|
|
||||||
if (function_exists('posix_isatty') && !posix_isatty(STDOUT)) {
|
|
||||||
PhutilConsoleFormatter::disableANSI(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$args = array_values($args);
|
$args = array_values($args);
|
||||||
$working_directory = getcwd();
|
$working_directory = getcwd();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if ($config_trace_mode) {
|
|
||||||
PhutilServiceProfiler::installEchoListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$args) {
|
if (!$args) {
|
||||||
throw new ArcanistUsageException("No command provided. Try 'arc help'.");
|
throw new ArcanistUsageException("No command provided. Try 'arc help'.");
|
||||||
}
|
}
|
||||||
|
@ -252,7 +243,7 @@ try {
|
||||||
$user_name = idx($host_config, 'user');
|
$user_name = idx($host_config, 'user');
|
||||||
$certificate = idx($host_config, 'cert');
|
$certificate = idx($host_config, 'cert');
|
||||||
|
|
||||||
$description = implode(' ', $argv);
|
$description = implode(' ', $original_argv);
|
||||||
$credentials = array(
|
$credentials = array(
|
||||||
'user' => $user_name,
|
'user' => $user_name,
|
||||||
'certificate' => $certificate,
|
'certificate' => $certificate,
|
||||||
|
|
Loading…
Reference in a new issue