Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14403395
D21085.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D21085.diff
View Options
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
@@ -370,6 +370,7 @@
'ArcanistPlusOperatorOnStringsXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistPlusOperatorOnStringsXHPASTLinterRuleTestCase.php',
'ArcanistProjectConfigurationSource' => 'config/source/ArcanistProjectConfigurationSource.php',
'ArcanistPrompt' => 'toolset/ArcanistPrompt.php',
+ 'ArcanistPromptsWorkflow' => 'toolset/workflow/ArcanistPromptsWorkflow.php',
'ArcanistPublicPropertyXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistPublicPropertyXHPASTLinterRule.php',
'ArcanistPublicPropertyXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistPublicPropertyXHPASTLinterRuleTestCase.php',
'ArcanistPuppetLintLinter' => 'lint/linter/ArcanistPuppetLintLinter.php',
@@ -1330,6 +1331,7 @@
'ArcanistPlusOperatorOnStringsXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistProjectConfigurationSource' => 'ArcanistWorkingCopyConfigurationSource',
'ArcanistPrompt' => 'Phobject',
+ 'ArcanistPromptsWorkflow' => 'ArcanistWorkflow',
'ArcanistPublicPropertyXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistPublicPropertyXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistPuppetLintLinter' => 'ArcanistExternalLinter',
diff --git a/src/toolset/workflow/ArcanistPromptsWorkflow.php b/src/toolset/workflow/ArcanistPromptsWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/toolset/workflow/ArcanistPromptsWorkflow.php
@@ -0,0 +1,80 @@
+<?php
+
+final class ArcanistPromptsWorkflow extends ArcanistWorkflow {
+
+ public function supportsToolset(ArcanistToolset $toolset) {
+ return true;
+ }
+
+ public function getWorkflowName() {
+ return 'prompts';
+ }
+
+ public function getWorkflowInformation() {
+ $help = pht(<<<EOTEXT
+Show information about prompts a workflow may execute and configure default
+responses.
+
+**Show Prompts**
+
+To show possible prompts a workflow may execute, run:
+
+ $ arc prompts <workflow>
+EOTEXT
+);
+
+ return $this->newWorkflowInformation()
+ ->addExample(pht('**prompts** __workflow__'))
+ ->setHelp($help);
+ }
+
+ public function getWorkflowArguments() {
+ return array(
+ $this->newWorkflowArgument('argv')
+ ->setWildcard(true),
+ );
+ }
+
+ public function runWorkflow() {
+ $argv = $this->getArgument('argv');
+
+ if (!$argv) {
+ throw new PhutilArgumentUsageException(
+ pht('Provide a workflow to list prompts for.'));
+ }
+
+ $runtime = $this->getRuntime();
+ $workflows = $runtime->getWorkflows();
+
+ $workflow_key = array_shift($argv);
+ $workflow = idx($workflows, $workflow_key);
+
+ if (!$workflow) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Workflow "%s" is unknown. Supported workflows are: %s.',
+ $workflow_key,
+ implode(', ', array_keys($workflows))));
+ }
+
+ $prompts = $workflow->getPromptMap();
+ if (!$prompts) {
+ echo tsprintf(
+ "%s\n",
+ pht('This workflow does not have any prompts.'));
+ return 0;
+ }
+
+ foreach ($prompts as $prompt) {
+ echo tsprintf(
+ "**%s**\n",
+ $prompt->getKey());
+ echo tsprintf(
+ "%s\n",
+ $prompt->getDescription());
+ }
+
+ return 0;
+ }
+
+}
diff --git a/src/toolset/workflow/ArcanistShellCompleteWorkflow.php b/src/toolset/workflow/ArcanistShellCompleteWorkflow.php
--- a/src/toolset/workflow/ArcanistShellCompleteWorkflow.php
+++ b/src/toolset/workflow/ArcanistShellCompleteWorkflow.php
@@ -226,7 +226,10 @@
$log->writeSuccess(
pht('INSTALL'),
- pht('Installing shell completion support for "%s".', $shell));
+ pht(
+ 'Installing shell completion support for "%s" into "%s".',
+ $shell,
+ $file_display));
if ($replace) {
$replace_pos = $matches[0][1];
diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php
--- a/src/workflow/ArcanistWorkflow.php
+++ b/src/workflow/ArcanistWorkflow.php
@@ -77,6 +77,7 @@
private $configurationSourceList;
private $hardpointEngine;
+ private $promptMap;
final public function setToolset(ArcanistToolset $toolset) {
$this->toolset = $toolset;
@@ -2333,4 +2334,63 @@
return $engine;
}
+ protected function newPrompts() {
+ return array();
+ }
+
+ protected function newPrompt($key) {
+ return id(new ArcanistPrompt())
+ ->setWorkflow($this)
+ ->setKey($key);
+ }
+
+ public function hasPrompt($key) {
+ $map = $this->getPromptMap();
+ return isset($map[$key]);
+ }
+
+ public function getPromptMap() {
+ if ($this->promptMap === null) {
+ $prompts = $this->newPrompts();
+ assert_instances_of($prompts, 'ArcanistPrompt');
+
+ $map = array();
+ foreach ($prompts as $prompt) {
+ $key = $prompt->getKey();
+
+ if (isset($map[$key])) {
+ throw new Exception(
+ pht(
+ 'Workflow ("%s") generates two prompts with the same '.
+ 'key ("%s"). Each prompt a workflow generates must have a '.
+ 'unique key.',
+ get_class($this),
+ $key));
+ }
+
+ $map[$key] = $prompt;
+ }
+
+ $this->promptMap = $map;
+ }
+
+ return $this->promptMap;
+ }
+
+ protected function getPrompt($key) {
+ $map = $this->getPromptMap();
+
+ $prompt = idx($map, $key);
+ if (!$prompt) {
+ throw new Exception(
+ pht(
+ 'Workflow ("%s") is requesting a prompt ("%s") but it did not '.
+ 'generate any prompt with that name in "newPrompts()".',
+ get_class($this),
+ $key));
+ }
+
+ return clone $prompt;
+ }
+
}
diff --git a/support/shell/hooks/bash-completion.sh b/support/shell/hooks/bash-completion.sh
--- a/support/shell/hooks/bash-completion.sh
+++ b/support/shell/hooks/bash-completion.sh
@@ -1,9 +1,10 @@
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
+GENERATED_RULES_FILE="${SCRIPTDIR}/../rules/bash-rules.sh"
# Try to generate the shell completion rules if they do not yet exist.
-if [ ! -f "${SCRIPTDIR}/bash-rules.sh" ]; then
+if [ ! -f "${GENERATED_RULES_FILE}" ]; then
arc shell-complete --generate >/dev/null 2>/dev/null
fi;
# Source the shell completion rules.
-source "${SCRIPTDIR}/../rules/bash-rules.sh"
+source "${GENERATED_RULES_FILE}"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 2:26 AM (18 h, 31 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6922711
Default Alt Text
D21085.diff (6 KB)
Attached To
Mode
D21085: Port "arc prompts" from wilds and fix a path issue in shell completion
Attached
Detach File
Event Timeline
Log In to Comment