From e88668207fb21c9e052cfc47f12fdb736e564be0 Mon Sep 17 00:00:00 2001 From: "l.weber" Date: Tue, 12 Aug 2025 11:16:40 +0200 Subject: [PATCH] add flags for bin colors --- main.go | 11 ++++++++++- ntfy.go | 26 ++++++++++++++++++++------ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index d8992d6..6795ee4 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,11 @@ func main() { var args struct { Street string `arg:"positional,required"` Home int `arg:"positional,required"` + Pink bool `arg:"--pink"` + Yellow bool `arg:"--yellow"` + Blue bool `arg:"--blue"` + Gray bool `arg:"--gray"` + Brown bool `arg:"--brown"` } parser, err := arg.NewParser(arg.Config{}, &args) @@ -20,6 +25,10 @@ func main() { } parser.MustParse(os.Args[1:]) + if !(args.Pink || args.Yellow || args.Blue || args.Gray || args.Brown) { + args.Pink, args.Yellow, args.Blue, args.Gray, args.Brown = true, true, true, true, true + } + NotifyChannel = fmt.Sprintf("%s-%d", args.Street, args.Home) streetNumbers, err := GetStreetNumbers() @@ -43,7 +52,7 @@ func main() { return } - err = SendAwlNotification(tomorrow) + err = SendAwlNotification(tomorrow, args.Pink, args.Yellow, args.Blue, args.Gray, args.Brown) if err != nil { _ = SendErr(err) return diff --git a/ntfy.go b/ntfy.go index 2b1e298..a3e34f4 100644 --- a/ntfy.go +++ b/ntfy.go @@ -8,23 +8,37 @@ import ( var NotifyChannel string -func SendAwlNotification(binColors []string) error { +func SendAwlNotification(binColors []string, pink, yellow, blue, gray, brown bool) error { var bins = make([]string, 0, 5) for _, color := range binColors { switch color { case "pink": - bins = append(bins, "🟣 Pink") + if pink { + bins = append(bins, "🟣 Pink") + } case "gelb": - bins = append(bins, "🟡 Gelb") + if yellow { + bins = append(bins, "🟡 Gelb") + } case "blau": - bins = append(bins, "🔵 Blau") + if blue { + bins = append(bins, "🔵 Blau") + } case "grau": - bins = append(bins, "⚫ Grau") + if gray { + bins = append(bins, "⚫ Grau") + } case "braun": - bins = append(bins, "🟤 Braun") + if brown { + bins = append(bins, "🟤 Braun") + } } } + if len(bins) == 0 { + return nil + } + var message string if len(bins) == 1 { message = "Morgen wird folgende Tonne abgeholt: "