Skip to content

Commit beeb35e

Browse files
committed
clean up body prompt text
1 parent 1e19b99 commit beeb35e

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

command/editor.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io/ioutil"
99
"os"
1010
"os/exec"
11+
"path/filepath"
1112
"runtime"
1213

1314
"github.com/AlecAivazis/survey/v2"
@@ -46,18 +47,28 @@ var EditorQuestionTemplate = `
4647
{{- else }}
4748
{{- if and .Help (not .ShowHelp)}}{{color "cyan"}}[{{ .Config.HelpInput }} for help]{{color "reset"}} {{end}}
4849
{{- if and .Default (not .HideDefault)}}{{color "white"}}({{.Default}}) {{color "reset"}}{{end}}
49-
{{- color "cyan"}}[e: launch editor][enter: skip for now] {{color "reset"}}
50+
{{- color "cyan"}}[e: launch {{ .EditorName }}][enter: skip for now] {{color "reset"}}
5051
{{- end}}`
5152

53+
type EditorTemplateData struct {
54+
survey.Editor
55+
EditorName string
56+
Answer string
57+
ShowAnswer bool
58+
ShowHelp bool
59+
Config *survey.PromptConfig
60+
}
61+
5262
// this is not being called in the embedding case and isn't consulted in the alias case because of
5363
// the incomplete overriding.
5464
func (e *ghEditor) prompt(initialValue string, config *survey.PromptConfig) (interface{}, error) {
5565
// render the template
5666
err := e.Render(
5767
EditorQuestionTemplate,
58-
survey.EditorTemplateData{
59-
Editor: *e.Editor,
60-
Config: config,
68+
EditorTemplateData{
69+
Editor: *e.Editor,
70+
EditorName: filepath.Base(editor),
71+
Config: config,
6172
},
6273
)
6374
if err != nil {
@@ -93,10 +104,11 @@ func (e *ghEditor) prompt(initialValue string, config *survey.PromptConfig) (int
93104
if string(r) == config.HelpInput && e.Help != "" {
94105
err = e.Render(
95106
EditorQuestionTemplate,
96-
survey.EditorTemplateData{
97-
Editor: *e.Editor,
98-
ShowHelp: true,
99-
Config: config,
107+
EditorTemplateData{
108+
Editor: *e.Editor,
109+
EditorName: filepath.Base(editor),
110+
ShowHelp: true,
111+
Config: config,
100112
},
101113
)
102114
if err != nil {

command/title_body_survey.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package command
22

33
import (
4-
"fmt"
5-
64
"github.com/AlecAivazis/survey/v2"
75
"github.com/github/gh-cli/pkg/githubtemplate"
86
"github.com/pkg/errors"
@@ -99,7 +97,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle string, providedBody stri
9997
Name: "body",
10098
Prompt: &ghEditor{
10199
Editor: &survey.Editor{
102-
Message: fmt.Sprintf("Body (%s)", editor),
100+
Message: "Body",
103101
FileName: "*.md",
104102
Default: inProgress.Body,
105103
HideDefault: true,

0 commit comments

Comments
 (0)