Make the X in the error message red and print with io writer

This commit is contained in:
Tyler McGoffin 2024-10-08 16:03:14 -07:00
parent 5fc311374a
commit be3b6cbd8d
3 changed files with 7 additions and 4 deletions

View file

@ -222,7 +222,7 @@ func createRun(opts *CreateOptions) (err error) {
defer prShared.PreserveInput(opts.IO, &tb, &err)()
if opts.Title == "" {
err = prShared.TitleSurvey(opts.Prompter, &tb)
err = prShared.TitleSurvey(opts.Prompter, opts.IO, &tb)
if err != nil {
return
}

View file

@ -379,7 +379,7 @@ func createRun(opts *CreateOptions) (err error) {
} else {
if !opts.TitleProvided {
err = shared.TitleSurvey(opts.Prompter, state)
err = shared.TitleSurvey(opts.Prompter, opts.IO, state)
if err != nil {
return
}

View file

@ -110,7 +110,7 @@ func BodySurvey(p Prompt, state *IssueMetadataState, templateContent string) err
return nil
}
func TitleSurvey(p Prompt, state *IssueMetadataState) error {
func TitleSurvey(p Prompt, io *iostreams.IOStreams, state *IssueMetadataState) error {
var err error
result := ""
for result == "" {
@ -119,7 +119,10 @@ func TitleSurvey(p Prompt, state *IssueMetadataState) error {
return err
}
if result == "" {
fmt.Println("X Title cannot be blank.")
colorizeRed := io.ColorScheme().ColorFromString("red")
msg := fmt.Sprintf("%s Title cannot be blank.", colorizeRed("X"))
// For some reason, only Fprintln and Println work here. I can't use Fprintf or Printf to eliminate the line above
fmt.Fprintln(io.ErrOut, msg)
}
}