nix-amer/internal/instruction/delete.go

36 lines
584 B
Go
Raw Normal View History

package instruction
import (
"fmt"
"strings"
)
type delete struct {
2018-11-10 12:20:10 +00:00
raw string
Packages []string
}
func (d *delete) Raw() string { return strings.Join([]string{"delete", d.raw}, " ") }
2018-11-10 12:20:10 +00:00
func (d *delete) Build(_args string) error {
d.Packages = strings.Split(_args, " ")
2018-11-10 12:20:10 +00:00
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
}