32 lines
465 B
Go
32 lines
465 B
Go
|
package instruction
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
type delete struct {
|
||
|
Packages []string
|
||
|
}
|
||
|
|
||
|
func (d *delete) Build(_args string) error {
|
||
|
d.Packages = strings.Split(_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
|
||
|
|
||
|
}
|