smartconfig/resolver_exec.go
sneak 8a38afba5e passes tests, has cli filter now.
* still has not been *really* tested yet
2025-07-20 15:29:06 +02:00

22 lines
495 B
Go

package smartconfig
import (
"fmt"
"os/exec"
"strings"
)
// ExecResolver executes shell commands and returns their output.
// Usage: ${EXEC:command}
type ExecResolver struct{}
// Resolve executes the command and returns its output.
func (r *ExecResolver) Resolve(value string) (string, error) {
cmd := exec.Command("sh", "-c", value)
output, err := cmd.Output()
if err != nil {
return "", fmt.Errorf("exec command failed: %w", err)
}
return strings.TrimSpace(string(output)), nil
}