package ser import ( "github.com/xdrm-brackets/nix-amer/internal/exec" ) type systemd struct{ exec exec.Executor } // available actions var actions = []string{"enable", "disable", "status", "start", "stop", "reload", "restart"} func (d *systemd) SetExecutor(_exec exec.Executor) { d.exec = _exec } func (d systemd) Name() string { return "systemctl" } func (d systemd) Exec(action, service string) error { // 1. fail if unknown action known := false for _, act := range actions { if action == act { known = true break } } if !known { return ErrUnknownAction } // 2. execute command return d.exec.Command("systemctl", action, service).Run() }