add flags for bin colors
This commit is contained in:
parent
cb42bee299
commit
e88668207f
2 changed files with 30 additions and 7 deletions
11
main.go
11
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
|
||||
|
|
|
|||
26
ntfy.go
26
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: "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue