Skip to content

Commit

Permalink
Add missing string setter
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed Nov 17, 2024
1 parent 735d75e commit 7a70c33
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions provider/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 7a70c33

Please sign in to comment.