From 759a7025ef76300bb7613501b0c2584470055249 Mon Sep 17 00:00:00 2001 From: nobe4 Date: Wed, 2 Oct 2024 14:29:20 +0200 Subject: [PATCH] feat(config): enable passing arguments to the rule This build on #188 and allow to specify arguments in the rules. E.g. ```yaml rules: - name: test action: debug args: ["a", "b"] ``` cc #187 --- internal/config/rule.go | 3 +++ internal/manager/manager.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/config/rule.go b/internal/config/rule.go index 31bd1aa..b0edd55 100644 --- a/internal/config/rule.go +++ b/internal/config/rule.go @@ -38,6 +38,9 @@ type Rule struct { // Action is the action to take on the filtered notifications. // See github.com/nobe4/internal/actions for list of available actions. Action string `mapstructure:"action"` + + // Args is the arguments to pass to the Action. + Args []string `mapstructure:"args"` } // Test tests the rule for correctness. diff --git a/internal/manager/manager.go b/internal/manager/manager.go index ec443bb..63997e9 100644 --- a/internal/manager/manager.go +++ b/internal/manager/manager.go @@ -128,7 +128,7 @@ func (m *Manager) Apply() error { continue } - if err := runner.Run(notification, nil, os.Stdout); err != nil { + if err := runner.Run(notification, rule.Args, os.Stdout); err != nil { slog.Error("action failed", "action", rule.Action, "err", err) } fmt.Fprintln(os.Stdout, "")