mirror of
https://github.com/ivabus/pop
synced 2025-06-08 08:00:27 +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.",
|
Short: "email is a command line interface for sending emails.",
|
||||||
Long: `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 {
|
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() {
|
if hasStdin() {
|
||||||
b, err := io.ReadAll(os.Stdin)
|
b, err := io.ReadAll(os.Stdin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -82,13 +88,6 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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()
|
err := rootCmd.Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
Loading…
Reference in a new issue