From 7a70c336730258c5b1955ae32e069d5f99338c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Sun, 17 Nov 2024 18:32:06 +0100 Subject: [PATCH] Add missing string setter --- provider/script.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/provider/script.go b/provider/script.go index 7ed25cb63f..e7a30425b8 100644 --- a/provider/script.go +++ b/provider/script.go @@ -161,3 +161,20 @@ func (p *Script) BoolSetter(param string) (func(bool) error, error) { return err }, nil } + +var _ SetStringProvider = (*Script)(nil) + +// StringSetter returns a function that invokes a script with parameter by a string value +func (p *Script) StringSetter(param string) (func(string) error, error) { + return func(v string) error { + cmd, err := util.ReplaceFormatted(p.script, map[string]interface{}{ + param: v, + }) + + if err == nil { + _, err = p.exec(cmd) + } + + return err + }, nil +}