From 6dc04af6e808f44f3a009ebbdbf0bd6d5efad5c3 Mon Sep 17 00:00:00 2001 From: Aviv Eyal Date: Fri, 25 Oct 2013 15:57:38 -0700 Subject: [PATCH] Specify custom arcrc filename Summary: allow specifing an replacement .arcrc file, for the odd cases. Test Plan: `echo {} | arc call-conduit user.whoami` with and without `--arcrc-file=` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, aran Differential Revision: https://secure.phabricator.com/D7208 --- scripts/arcanist.php | 8 ++++++++ .../ArcanistConfigurationManager.php | 15 ++++++++++++++- src/workflow/ArcanistHelpWorkflow.php | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/arcanist.php b/scripts/arcanist.php index 0d35fc95..4e0051b3 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -21,6 +21,10 @@ $args->parsePartial( array( 'name' => 'skip-arcconfig', ), + array( + 'name' => 'arcrc-file', + 'param' => 'filename', + ), array( 'name' => 'conduit-uri', 'param' => 'uri', @@ -44,6 +48,7 @@ $force_conduit = $args->getArg('conduit-uri'); $force_conduit_version = $args->getArg('conduit-version'); $conduit_timeout = $args->getArg('conduit-timeout'); $skip_arcconfig = $args->getArg('skip-arcconfig'); +$custom_arcrc = $args->getArg('arcrc-file'); $load = $args->getArg('load-phutil-library'); $help = $args->getArg('help'); @@ -136,6 +141,9 @@ try { $working_copy); } + if ($custom_arcrc) { + $configuration_manager->setUserConfigurationFileLocation($custom_arcrc); + } $user_config = $configuration_manager->readUserConfigurationFile(); $config_class = $working_copy->getProjectConfig('arcanist_configuration'); diff --git a/src/configuration/ArcanistConfigurationManager.php b/src/configuration/ArcanistConfigurationManager.php index 04494b90..79c5a756 100644 --- a/src/configuration/ArcanistConfigurationManager.php +++ b/src/configuration/ArcanistConfigurationManager.php @@ -9,6 +9,7 @@ final class ArcanistConfigurationManager { private $runtimeConfig = array(); private $workingCopy = null; + private $customArcrcFilename = null; public function setWorkingCopyIdentity( ArcanistWorkingCopyIdentity $working_copy) { @@ -147,7 +148,6 @@ final class ArcanistConfigurationManager { return false; } - /** * This is probably not the method you're looking for; try * @{method:readUserArcConfig}. @@ -204,7 +204,20 @@ final class ArcanistConfigurationManager { } } + public function setUserConfigurationFileLocation($custom_arcrc) { + if (!Filesystem::pathExists($custom_arcrc)) { + throw new Exception( + "Custom arcrc file was specified, but it was not found!"); + } + + $this->customArcrcFilename = $custom_arcrc; + } + public function getUserConfigurationFileLocation() { + if (strlen($this->customArcrcFilename)) { + return $this->customArcrcFilename; + } + if (phutil_is_windows()) { return getenv('APPDATA').'/.arcrc'; } else { diff --git a/src/workflow/ArcanistHelpWorkflow.php b/src/workflow/ArcanistHelpWorkflow.php index 8b358e33..7b755235 100644 --- a/src/workflow/ArcanistHelpWorkflow.php +++ b/src/workflow/ArcanistHelpWorkflow.php @@ -199,6 +199,11 @@ EOTEXT __--conduit-timeout__ __timeout__ Override the default Conduit timeout. Specified in seconds. + __--skip-arcconfig__ + Skip the working copy configuration file + + __--arcrc-file__ __filename__ + Use provided file instead of ~/.arcrc. EOTEXT ); } -- 2.43.0