1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-10 00:42:40 +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:
epriestley 2012-03-08 12:20:26 -08:00
parent 465ad3fa44
commit 92febf184e

View file

@ -34,20 +34,20 @@ phutil_require_module('arcanist', 'repository/api/base');
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;
$args = array_slice($argv, 1);
$args = $argv;
$load = array();
$matches = null;
foreach ($args as $key => $arg) {
if ($arg == '--') {
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)) {
unset($args[$key]);
$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);
$working_directory = getcwd();
try {
if ($config_trace_mode) {
PhutilServiceProfiler::installEchoListener();
}
if (!$args) {
throw new ArcanistUsageException("No command provided. Try 'arc help'.");
}
@ -252,7 +243,7 @@ try {
$user_name = idx($host_config, 'user');
$certificate = idx($host_config, 'cert');
$description = implode(' ', $argv);
$description = implode(' ', $original_argv);
$credentials = array(
'user' => $user_name,
'certificate' => $certificate,