40 lines
667 B
Go
40 lines
667 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
|
|
|
|
}
|
|
|
|
func (d delete) DryRun(ctx ExecutionContext) ([]byte, error) {
|
|
return nil, nil
|
|
}
|