From 10c7b1d96a8c2fd4c5eb3c1eac572bd7b275f349 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Mon, 10 Jul 2023 12:37:02 -0400 Subject: [PATCH] feat: `--preview` flag --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 330a34b..a70d267 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ var ( subject string body string attachments []string + preview bool ) var rootCmd = &cobra.Command{ @@ -41,7 +42,7 @@ var rootCmd = &cobra.Command{ body = string(b) } - if len(to) > 0 && from != "" && subject != "" && body != "" { + if len(to) > 0 && from != "" && subject != "" && body != "" && !preview { err := sendEmail(to, from, subject, body, attachments) if err != nil { cmd.SilenceUsage = true @@ -86,6 +87,7 @@ func init() { rootCmd.Flags().StringVarP(&body, "body", "b", "", "Email's contents") rootCmd.Flags().StringVarP(&from, "from", "f", os.Getenv(RESEND_FROM), "Email's sender "+commentStyle.Render("($RESEND_FROM)")) rootCmd.Flags().StringVarP(&subject, "subject", "s", "", "Email's subject") + rootCmd.Flags().BoolVarP(&preview, "preview", "p", false, "Whether to preview the email before sending") } func main() {