From 9641eee38ac253d2468fd7e4f864eb2d1cf4cbd7 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Wed, 22 Apr 2020 14:31:09 -0500 Subject: [PATCH] use more clear name --- command/title_body_survey.go | 4 ++-- pkg/surveyext/editor.go | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/command/title_body_survey.go b/command/title_body_survey.go index 2f6270c36..c2b68ec8d 100644 --- a/command/title_body_survey.go +++ b/command/title_body_survey.go @@ -87,7 +87,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle, providedBody string, def if err != nil { return nil, fmt.Errorf("could not read config: %w", err) } - editorName, _ := cfg.Get(defaultHostname, "editor") + editorCommand, _ := cfg.Get(defaultHostname, "editor") var inProgress titleBody inProgress.Title = defs.Title @@ -116,7 +116,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle, providedBody string, def bodyQuestion := &survey.Question{ Name: "body", Prompt: &surveyext.GhEditor{ - EditorName: editorName, + EditorCommand: editorCommand, Editor: &survey.Editor{ Message: "Body", FileName: "*.md", diff --git a/pkg/surveyext/editor.go b/pkg/surveyext/editor.go index 4ed0c2844..3121ccf4d 100644 --- a/pkg/surveyext/editor.go +++ b/pkg/surveyext/editor.go @@ -37,15 +37,15 @@ func init() { // EXTENDED to enable different prompting behavior type GhEditor struct { *survey.Editor - EditorName string + EditorCommand string } -func (e *GhEditor) editorName() string { - if e.EditorName == "" { +func (e *GhEditor) editorCommand() string { + if e.EditorCommand == "" { return defaultEditor } - return e.EditorName + return e.EditorCommand } // EXTENDED to change prompt text @@ -58,17 +58,17 @@ var EditorQuestionTemplate = ` {{- else }} {{- if and .Help (not .ShowHelp)}}{{color "cyan"}}[{{ .Config.HelpInput }} for help]{{color "reset"}} {{end}} {{- if and .Default (not .HideDefault)}}{{color "white"}}({{.Default}}) {{color "reset"}}{{end}} - {{- color "cyan"}}[(e) to launch {{ .EditorName }}, enter to skip] {{color "reset"}} + {{- color "cyan"}}[(e) to launch {{ .EditorCommand }}, enter to skip] {{color "reset"}} {{- end}}` // EXTENDED to pass editor name (to use in prompt) type EditorTemplateData struct { survey.Editor - EditorName string - Answer string - ShowAnswer bool - ShowHelp bool - Config *survey.PromptConfig + EditorCommand string + Answer string + ShowAnswer bool + ShowHelp bool + Config *survey.PromptConfig } // EXTENDED to augment prompt text and keypress handling @@ -77,9 +77,9 @@ func (e *GhEditor) prompt(initialValue string, config *survey.PromptConfig) (int EditorQuestionTemplate, // EXTENDED to support printing editor in prompt EditorTemplateData{ - Editor: *e.Editor, - EditorName: filepath.Base(e.editorName()), - Config: config, + Editor: *e.Editor, + EditorCommand: filepath.Base(e.editorCommand()), + Config: config, }, ) if err != nil { @@ -118,10 +118,10 @@ func (e *GhEditor) prompt(initialValue string, config *survey.PromptConfig) (int EditorQuestionTemplate, EditorTemplateData{ // EXTENDED to support printing editor in prompt - Editor: *e.Editor, - EditorName: filepath.Base(e.editorName()), - ShowHelp: true, - Config: config, + Editor: *e.Editor, + EditorCommand: filepath.Base(e.editorCommand()), + ShowHelp: true, + Config: config, }, ) if err != nil { @@ -164,7 +164,7 @@ func (e *GhEditor) prompt(initialValue string, config *survey.PromptConfig) (int stdio := e.Stdio() - args, err := shellquote.Split(e.editorName()) + args, err := shellquote.Split(e.editorCommand()) if err != nil { return "", err }