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