36 lines
584 B
Go
36 lines
584 B
Go
package instruction
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type delete struct {
|
|
raw string
|
|
Packages []string
|
|
}
|
|
|
|
func (d *delete) Raw() string { return strings.Join([]string{"delete", 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
|
|
|
|
}
|