エラーチェック

This commit is contained in:
ry.yamafuji 2025-12-24 20:57:08 +09:00
parent 71ea80bd4a
commit 66fdf87fc0

View File

@ -48,6 +48,16 @@ func run(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
return 0
}
// webhook URL の解決: flag > env
webhookURL := strings.TrimSpace(opt.WebhookURL)
if webhookURL == "" {
webhookURL = strings.TrimSpace(os.Getenv("SLACK_WEBHOOK_URL"))
}
if webhookURL == "" {
fmt.Fprintln(stderr, "Slack webhook URL is required. Set --webhook or SLACK_WEBHOOK_URL.")
return 2
}
msg, err := message(fs.Args(), stdin)
if err != nil {
fmt.Fprintln(stderr, "read message error:", err)