Page MenuHomePhabricator

D16928.diff
No OneTemporary

D16928.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -350,6 +350,7 @@
'ArcanistSemicolonSpacingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistSemicolonSpacingXHPASTLinterRule.php',
'ArcanistSemicolonSpacingXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistSemicolonSpacingXHPASTLinterRuleTestCase.php',
'ArcanistSetConfigWorkflow' => 'workflow/ArcanistSetConfigWorkflow.php',
+ 'ArcanistSetting' => 'configuration/ArcanistSetting.php',
'ArcanistSettings' => 'configuration/ArcanistSettings.php',
'ArcanistShellCompleteWorkflow' => 'workflow/ArcanistShellCompleteWorkflow.php',
'ArcanistSingleLintEngine' => 'lint/engine/ArcanistSingleLintEngine.php',
@@ -787,6 +788,7 @@
'ArcanistSemicolonSpacingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistSemicolonSpacingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistSetConfigWorkflow' => 'ArcanistWorkflow',
+ 'ArcanistSetting' => 'Phobject',
'ArcanistSettings' => 'Phobject',
'ArcanistShellCompleteWorkflow' => 'ArcanistWorkflow',
'ArcanistSingleLintEngine' => 'ArcanistLintEngine',
diff --git a/src/browse/workflow/ArcanistBrowseWorkflow.php b/src/browse/workflow/ArcanistBrowseWorkflow.php
--- a/src/browse/workflow/ArcanistBrowseWorkflow.php
+++ b/src/browse/workflow/ArcanistBrowseWorkflow.php
@@ -154,6 +154,9 @@
}
}
+ $pick_map = array();
+ $pick_selection = null;
+ $pick_id = 0;
if ($many_hits) {
foreach ($many_hits as $ref) {
$token = $ref->getToken();
@@ -166,8 +169,17 @@
$this->writeWarn(pht('AMBIGUOUS'), $message);
}
- $table = id(new PhutilConsoleTable())
- ->addColumn('argument', array('title' => pht('Argument')))
+ $is_single_ref = (count($refs) == 1);
+
+ $table = id(new PhutilConsoleTable());
+
+ if ($is_single_ref) {
+ $table->addColumn('pick', array('title' => pht('Pick')));
+ } else {
+ $table->addColumn('argument', array('title' => pht('Argument')));
+ }
+
+ $table
->addColumn('type', array('title' => pht('Type')))
->addColumn('uri', array('title' => pht('URI')));
@@ -178,7 +190,11 @@
}
foreach ($ref->getURIs() as $uri) {
+ ++$pick_id;
+ $pick_map[$pick_id] = $uri;
+
$row = array(
+ 'pick' => $pick_id,
'argument' => $token_display,
'type' => $uri->getType(),
'uri' => $uri->getURI(),
@@ -190,9 +206,17 @@
$table->draw();
- $this->writeInfo(
- pht('CHOOSE'),
- pht('Use "--types" to select between alternatives.'));
+ if ($is_single_ref) {
+ $pick_selection = phutil_console_select(
+ pht('Which URI do you want to open?'),
+ 1,
+ $pick_id);
+ $open_uris[] = $ref;
+ } else {
+ $this->writeInfo(
+ pht('CHOOSE'),
+ pht('Use "--types" to select between alternatives.'));
+ }
}
// If anything failed to resolve, this is also an error.
@@ -212,7 +236,17 @@
$uris = array();
foreach ($open_uris as $ref) {
- $ref_uri = head($ref->getURIs());
+ $ref_uris = $ref->getURIs();
+
+ if (count($ref_uris) > 1) {
+ foreach ($ref_uris as $uri_key => $uri) {
+ if ($pick_map[$pick_selection] !== $uri) {
+ unset($ref_uris[$uri_key]);
+ }
+ }
+ }
+
+ $ref_uri = head($ref_uris);
$uris[] = $ref_uri->getURI();
}
diff --git a/src/configuration/ArcanistSetting.php b/src/configuration/ArcanistSetting.php
new file mode 100644
--- /dev/null
+++ b/src/configuration/ArcanistSetting.php
@@ -0,0 +1,48 @@
+<?php
+
+abstract class ArcanistSetting
+ extends Phobject {
+
+ final public function getSettingKey() {
+ return $this->getPhobjectClassConstant('SETTINGKEY', 32);
+ }
+
+ public function getAliases() {
+ return array();
+ }
+
+ abstract public function getHelp();
+ abstract public function getType();
+
+ public function getExample() {
+ return null;
+ }
+
+ final public function getLegacyDictionary() {
+ $result = array(
+ 'type' => $this->getType(),
+ 'help' => $this->getHelp(),
+ );
+
+ $example = $this->getExample();
+ if ($example !== null) {
+ $result['example'] = $example;
+ }
+
+ $aliases = $this->getAliases();
+ if ($aliases) {
+ $result['legacy'] = head($aliases);
+ }
+
+ return $result;
+ }
+
+ final public static function getAllSettings() {
+ return id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->setUniqueMethod('getSettingKey')
+ ->setSortMethod('getSettingKey')
+ ->execute();
+ }
+
+}
diff --git a/src/configuration/ArcanistSettings.php b/src/configuration/ArcanistSettings.php
--- a/src/configuration/ArcanistSettings.php
+++ b/src/configuration/ArcanistSettings.php
@@ -3,7 +3,7 @@
final class ArcanistSettings extends Phobject {
private function getOptions() {
- return array(
+ $legacy_builtins = array(
'default' => array(
'type' => 'string',
'help' => pht(
@@ -175,6 +175,16 @@
'Configured command aliases. Use "arc alias" to define aliases.'),
),
);
+
+ $settings = ArcanistSetting::getAllSettings();
+ foreach ($settings as $key => $setting) {
+ $settings[$key] = $setting->getLegacyDictionary();
+ }
+
+ $results = $settings + $legacy_builtins;
+ ksort($results);
+
+ return $results;
}
private function getOption($key) {

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 7, 11:51 PM (4 d, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6719119
Default Alt Text
D16928.diff (5 KB)

Event Timeline