pop/main.go

40 lines
882 B
Go
Raw Normal View History

2023-06-14 06:31:19 +03:00
package main
import (
2023-06-15 16:45:14 +03:00
"fmt"
2023-06-14 06:31:19 +03:00
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
)
2023-06-15 16:45:14 +03:00
const RESEND_API_KEY = "RESEND_API_KEY"
2023-06-14 06:31:19 +03:00
var rootCmd = &cobra.Command{
Use: "email",
Short: "email is a command line interface for sending emails.",
Long: `email is a command line interface for sending emails.`,
RunE: func(cmd *cobra.Command, args []string) error {
p := tea.NewProgram(NewModel())
_, err := p.Run()
if err != nil {
return err
}
return nil
},
}
func main() {
2023-06-15 16:45:14 +03:00
key := os.Getenv(RESEND_API_KEY)
if 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"))
os.Exit(1)
}
2023-06-14 06:31:19 +03:00
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}