From 71008451b1d02f8cdd3bc0ced8bcea12706174aa Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Tue, 20 Jun 2023 10:21:01 -0400 Subject: [PATCH] fix: separate email sent to links --- main.go | 2 +- style.go | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index dee217a..d9686e2 100644 --- a/main.go +++ b/main.go @@ -29,7 +29,7 @@ var rootCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { if os.Getenv(RESEND_API_KEY) == "" { fmt.Printf("\n %s %s %s\n\n", errorHeaderStyle.String(), inlineCodeStyle.Render(RESEND_API_KEY), "environment variable is required.") - fmt.Printf(" %s %s\n\n", commentStyle.Render("You can grab one at"), linkStyle.Render("https://resend.com")) + fmt.Printf(" %s %s\n\n", commentStyle.Render("You can grab one at"), linkStyle.Render("https://resend.com/api-keys")) os.Exit(1) } diff --git a/style.go b/style.go index 55e7e98..b2934cf 100644 --- a/style.go +++ b/style.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "strings" "github.com/charmbracelet/lipgloss" @@ -41,5 +40,17 @@ var ( // emailSummary returns a summary of the email that was sent. It is used when // the user has sent an email successfully. func emailSummary(to []string, subject string) string { - return fmt.Sprintf("\n Email %s sent to %s\n\n", activeTextStyle.Render("\""+subject+"\""), linkStyle.Render(strings.Join(to, ", "))) + var s strings.Builder + s.WriteString("\n Email ") + s.WriteString(activeTextStyle.Render("\"" + subject + "\"")) + s.WriteString(" sent to ") + for i, t := range to { + if i > 0 { + s.WriteString(", ") + } + s.WriteString(linkStyle.Render(t)) + } + s.WriteString("\n\n") + + return s.String() }