nix-amer/internal/instruction/delete.go

36 lines
545 B
Go

package instruction
import (
"fmt"
"strings"
)
type delete struct {
raw string
Packages []string
}
func (d *delete) Raw() string { return d.raw }
func (d *delete) Build(_args string) error {
d.Packages = strings.Split(_args, " ")
d.raw = _args
return nil
}
func (d delete) Exec(ctx ExecutionContext) ([]byte, error) {
// delete all packages
for _, pkg := range d.Packages {
err := ctx.PackageManager.Remove(pkg)
if err != nil {
return nil, fmt.Errorf("cannot delete '%s' | %s", pkg, err)
}
}
return nil, nil
}