Skip to content

Commit 9641eee

Browse files
committed
use more clear name
1 parent 3c8b87c commit 9641eee

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

command/title_body_survey.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle, providedBody string, def
8787
if err != nil {
8888
return nil, fmt.Errorf("could not read config: %w", err)
8989
}
90-
editorName, _ := cfg.Get(defaultHostname, "editor")
90+
editorCommand, _ := cfg.Get(defaultHostname, "editor")
9191

9292
var inProgress titleBody
9393
inProgress.Title = defs.Title
@@ -116,7 +116,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle, providedBody string, def
116116
bodyQuestion := &survey.Question{
117117
Name: "body",
118118
Prompt: &surveyext.GhEditor{
119-
EditorName: editorName,
119+
EditorCommand: editorCommand,
120120
Editor: &survey.Editor{
121121
Message: "Body",
122122
FileName: "*.md",

pkg/surveyext/editor.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ func init() {
3737
// EXTENDED to enable different prompting behavior
3838
type GhEditor struct {
3939
*survey.Editor
40-
EditorName string
40+
EditorCommand string
4141
}
4242

43-
func (e *GhEditor) editorName() string {
44-
if e.EditorName == "" {
43+
func (e *GhEditor) editorCommand() string {
44+
if e.EditorCommand == "" {
4545
return defaultEditor
4646
}
4747

48-
return e.EditorName
48+
return e.EditorCommand
4949
}
5050

5151
// EXTENDED to change prompt text
@@ -58,17 +58,17 @@ var EditorQuestionTemplate = `
5858
{{- else }}
5959
{{- if and .Help (not .ShowHelp)}}{{color "cyan"}}[{{ .Config.HelpInput }} for help]{{color "reset"}} {{end}}
6060
{{- if and .Default (not .HideDefault)}}{{color "white"}}({{.Default}}) {{color "reset"}}{{end}}
61-
{{- color "cyan"}}[(e) to launch {{ .EditorName }}, enter to skip] {{color "reset"}}
61+
{{- color "cyan"}}[(e) to launch {{ .EditorCommand }}, enter to skip] {{color "reset"}}
6262
{{- end}}`
6363

6464
// EXTENDED to pass editor name (to use in prompt)
6565
type EditorTemplateData struct {
6666
survey.Editor
67-
EditorName string
68-
Answer string
69-
ShowAnswer bool
70-
ShowHelp bool
71-
Config *survey.PromptConfig
67+
EditorCommand string
68+
Answer string
69+
ShowAnswer bool
70+
ShowHelp bool
71+
Config *survey.PromptConfig
7272
}
7373

7474
// EXTENDED to augment prompt text and keypress handling
@@ -77,9 +77,9 @@ func (e *GhEditor) prompt(initialValue string, config *survey.PromptConfig) (int
7777
EditorQuestionTemplate,
7878
// EXTENDED to support printing editor in prompt
7979
EditorTemplateData{
80-
Editor: *e.Editor,
81-
EditorName: filepath.Base(e.editorName()),
82-
Config: config,
80+
Editor: *e.Editor,
81+
EditorCommand: filepath.Base(e.editorCommand()),
82+
Config: config,
8383
},
8484
)
8585
if err != nil {
@@ -118,10 +118,10 @@ func (e *GhEditor) prompt(initialValue string, config *survey.PromptConfig) (int
118118
EditorQuestionTemplate,
119119
EditorTemplateData{
120120
// EXTENDED to support printing editor in prompt
121-
Editor: *e.Editor,
122-
EditorName: filepath.Base(e.editorName()),
123-
ShowHelp: true,
124-
Config: config,
121+
Editor: *e.Editor,
122+
EditorCommand: filepath.Base(e.editorCommand()),
123+
ShowHelp: true,
124+
Config: config,
125125
},
126126
)
127127
if err != nil {
@@ -164,7 +164,7 @@ func (e *GhEditor) prompt(initialValue string, config *survey.PromptConfig) (int
164164

165165
stdio := e.Stdio()
166166

167-
args, err := shellquote.Split(e.editorName())
167+
args, err := shellquote.Split(e.editorCommand())
168168
if err != nil {
169169
return "", err
170170
}

0 commit comments

Comments
 (0)