add flags for bin colors

This commit is contained in:
l.weber 2025-08-12 11:16:40 +02:00
parent cb42bee299
commit e88668207f
2 changed files with 30 additions and 7 deletions

11
main.go
View file

@ -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

16
ntfy.go
View file

@ -8,22 +8,36 @@ 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":
if pink {
bins = append(bins, "🟣 Pink")
}
case "gelb":
if yellow {
bins = append(bins, "🟡 Gelb")
}
case "blau":
if blue {
bins = append(bins, "🔵 Blau")
}
case "grau":
if gray {
bins = append(bins, "⚫ Grau")
}
case "braun":
if brown {
bins = append(bins, "🟤 Braun")
}
}
}
if len(bins) == 0 {
return nil
}
var message string
if len(bins) == 1 {