Files
thanks/internal/cmd/cmd.go
2026-01-30 15:14:25 -05:00

29 lines
528 B
Go

package cmd
import (
"context"
"fmt"
"os/exec"
)
type Runner interface {
Run(context.Context, string, ...any) ([]byte, error)
}
type ZRunner struct {
Prog string
Args []string
}
func (runner *ZRunner) Run(ctx context.Context, command string, formatArgs ...any) ([]byte, error) {
var subArgs string
if len(formatArgs) > 0 {
subArgs = fmt.Sprintf(command, formatArgs...)
} else {
subArgs = command
}
args := append(runner.Args, subArgs)
cmd := exec.Command(runner.Prog, args...)
return cmd.CombinedOutput()
}