clean up body prompt text

This commit is contained in:
vilmibm 2020-01-16 14:03:58 -06:00
parent 1e19b9953a
commit beeb35e7e2
2 changed files with 21 additions and 11 deletions

View file

@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
"github.com/AlecAivazis/survey/v2"
@ -46,18 +47,28 @@ 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: launch editor][enter: skip for now] {{color "reset"}}
{{- color "cyan"}}[e: launch {{ .EditorName }}][enter: skip for now] {{color "reset"}}
{{- end}}`
type EditorTemplateData struct {
survey.Editor
EditorName string
Answer string
ShowAnswer bool
ShowHelp bool
Config *survey.PromptConfig
}
// this is not being called in the embedding case and isn't consulted in the alias case because of
// the incomplete overriding.
func (e *ghEditor) prompt(initialValue string, config *survey.PromptConfig) (interface{}, error) {
// render the template
err := e.Render(
EditorQuestionTemplate,
survey.EditorTemplateData{
Editor: *e.Editor,
Config: config,
EditorTemplateData{
Editor: *e.Editor,
EditorName: filepath.Base(editor),
Config: config,
},
)
if err != nil {
@ -93,10 +104,11 @@ func (e *ghEditor) prompt(initialValue string, config *survey.PromptConfig) (int
if string(r) == config.HelpInput && e.Help != "" {
err = e.Render(
EditorQuestionTemplate,
survey.EditorTemplateData{
Editor: *e.Editor,
ShowHelp: true,
Config: config,
EditorTemplateData{
Editor: *e.Editor,
EditorName: filepath.Base(editor),
ShowHelp: true,
Config: config,
},
)
if err != nil {

View file

@ -1,8 +1,6 @@
package command
import (
"fmt"
"github.com/AlecAivazis/survey/v2"
"github.com/github/gh-cli/pkg/githubtemplate"
"github.com/pkg/errors"
@ -99,7 +97,7 @@ func titleBodySurvey(cmd *cobra.Command, providedTitle string, providedBody stri
Name: "body",
Prompt: &ghEditor{
Editor: &survey.Editor{
Message: fmt.Sprintf("Body (%s)", editor),
Message: "Body",
FileName: "*.md",
Default: inProgress.Body,
HideDefault: true,