オプションを追加する

This commit is contained in:
ry.yamafuji 2025-12-24 20:48:51 +09:00
parent ba12476800
commit c49288194e

View File

@ -12,6 +12,8 @@ import (
type Options struct { type Options struct {
ShowVersion bool ShowVersion bool
WebhookURL string
TimeoutSec int
} }
func Run(args []string) int { func Run(args []string) int {
@ -26,6 +28,10 @@ func run(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
var opt Options var opt Options
fs.BoolVar(&opt.ShowVersion, "version", false, "show version") fs.BoolVar(&opt.ShowVersion, "version", false, "show version")
fs.BoolVar(&opt.ShowVersion, "V", false, "show version (short)") fs.BoolVar(&opt.ShowVersion, "V", false, "show version (short)")
// other options
fs.StringVar(&opt.WebhookURL, "webhook", "", "Slack Incoming Webhook URL (or env SLACK_WEBHOOK_URL)")
fs.IntVar(&opt.TimeoutSec, "timeout", 10, "HTTP timeout seconds")
if err := fs.Parse(args[1:]); err != nil { if err := fs.Parse(args[1:]); err != nil {
if err == flag.ErrHelp { if err == flag.ErrHelp {