initial working command

This commit is contained in:
Sam Hoffman
2026-01-30 15:14:25 -05:00
commit e325fcca1a
5 changed files with 289 additions and 0 deletions

28
internal/cmd/cmd.go Normal file
View File

@@ -0,0 +1,28 @@
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()
}