mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-22 21:40:54 +01:00
Display informative message when arc launches an editor
Summary: Update `PhutilInteractiveEditor` to allow specifying a "task message" which will be displayed just prior to launching the user's editor. Refs T3271 Test Plan: I ran several `arc diff` commands in varying states to invoke my editor and verified that it printed out the text indicating that my editor was being launched. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin Maniphest Tasks: T3271 Differential Revision: https://secure.phabricator.com/D21700
This commit is contained in:
parent
41f6c6ecb2
commit
232363e387
4 changed files with 53 additions and 1 deletions
|
@ -22,6 +22,7 @@ final class PhutilInteractiveEditor extends Phobject {
|
|||
private $offset = 0;
|
||||
private $preferred;
|
||||
private $fallback;
|
||||
private $taskMessage;
|
||||
|
||||
|
||||
/* -( Creating a New Editor )---------------------------------------------- */
|
||||
|
@ -74,6 +75,20 @@ final class PhutilInteractiveEditor extends Phobject {
|
|||
$editor = $this->getEditor();
|
||||
$offset = $this->getLineOffset();
|
||||
|
||||
$binary = basename($editor);
|
||||
|
||||
// This message is primarily an assistance to users with GUI-based
|
||||
// editors configured. Users with terminal-based editors won't have a
|
||||
// chance to see this prior to the editor being launched.
|
||||
echo tsprintf(
|
||||
"%s\n",
|
||||
pht('Launching editor "%s"...', $binary));
|
||||
|
||||
$task_message = $this->getTaskMessage();
|
||||
if ($task_message !== null) {
|
||||
echo tsprintf("%s\n", $task_message);
|
||||
}
|
||||
|
||||
$err = $this->invokeEditor($editor, $path, $offset);
|
||||
|
||||
if ($err) {
|
||||
|
@ -85,7 +100,6 @@ final class PhutilInteractiveEditor extends Phobject {
|
|||
'vim' => true,
|
||||
);
|
||||
|
||||
$binary = basename($editor);
|
||||
if (isset($vi_binaries[$binary])) {
|
||||
// This runs "Q" (an invalid command), then "q" (a valid command,
|
||||
// meaning "quit"). Vim binaries with behavior that makes them poor
|
||||
|
@ -266,6 +280,33 @@ final class PhutilInteractiveEditor extends Phobject {
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message that identifies the task for which the editor is being
|
||||
* launched, displayed to the user prior to it being launched.
|
||||
*
|
||||
* @param string The message to display to the user.
|
||||
* @return $this
|
||||
*
|
||||
* @task config
|
||||
*/
|
||||
public function setTaskMessage($task_message) {
|
||||
$this->taskMessage = $task_message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current message that will display to the user just prior to
|
||||
* invoking the editor.
|
||||
*
|
||||
* @return string The message that will display to the user, or null if no
|
||||
* message will be displayed.
|
||||
*
|
||||
* @task config
|
||||
*/
|
||||
public function getTaskMessage() {
|
||||
return $this->taskMessage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of the editor program to use. The value of the environmental
|
||||
|
|
|
@ -674,6 +674,8 @@ EOTEXT
|
|||
if ($should_edit) {
|
||||
$edited = $this->newInteractiveEditor($remote_corpus)
|
||||
->setName('differential-edit-revision-info')
|
||||
->setTaskMessage(pht(
|
||||
'Update the details for a revision, then save and exit.'))
|
||||
->editInteractively();
|
||||
if ($edited != $remote_corpus) {
|
||||
$remote_corpus = $edited;
|
||||
|
@ -1476,6 +1478,8 @@ EOTEXT
|
|||
} else {
|
||||
$new_template = $this->newInteractiveEditor($template)
|
||||
->setName('new-commit')
|
||||
->setTaskMessage(pht(
|
||||
'Provide the details for a new revision, then save and exit.'))
|
||||
->editInteractively();
|
||||
}
|
||||
$first = false;
|
||||
|
@ -1752,6 +1756,8 @@ EOTEXT
|
|||
|
||||
$comments = $this->newInteractiveEditor($template)
|
||||
->setName('differential-update-comments')
|
||||
->setTaskMessage(pht(
|
||||
'Update the revision comments, then save and exit.'))
|
||||
->editInteractively();
|
||||
|
||||
return $comments;
|
||||
|
|
|
@ -909,6 +909,8 @@ EOTEXT
|
|||
|
||||
$commit_message = $this->newInteractiveEditor($template)
|
||||
->setName('arcanist-patch-commit-message')
|
||||
->setTaskMessage(pht(
|
||||
'Supply a commit message for this patch, then save and exit.'))
|
||||
->editInteractively();
|
||||
|
||||
$commit_message = ArcanistCommentRemover::removeComments($commit_message);
|
||||
|
|
|
@ -1234,6 +1234,9 @@ abstract class ArcanistWorkflow extends Phobject {
|
|||
|
||||
$commit_message = $this->newInteractiveEditor($template)
|
||||
->setName(pht('commit-message'))
|
||||
->setTaskMessage(pht(
|
||||
'Supply commit message for uncommitted changes, then save and '.
|
||||
'exit.'))
|
||||
->editInteractively();
|
||||
|
||||
if ($commit_message === $template) {
|
||||
|
|
Loading…
Reference in a new issue