mirror of
https://github.com/ivabus/pop
synced 2024-12-04 22:15:08 +03:00
fix: allow --help with API key
This commit is contained in:
parent
bc4cb4caf8
commit
72450a7fc6
1 changed files with 6 additions and 7 deletions
13
main.go
13
main.go
|
@ -27,6 +27,12 @@ var rootCmd = &cobra.Command{
|
|||
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 {
|
||||
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"))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if hasStdin() {
|
||||
b, err := io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
|
@ -82,13 +88,6 @@ func init() {
|
|||
}
|
||||
|
||||
func main() {
|
||||
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)
|
||||
}
|
||||
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
|
|
Loading…
Reference in a new issue