2018-11-08 12:41:07 +00:00
|
|
|
package instruction
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type install struct {
|
2018-11-10 12:20:10 +00:00
|
|
|
raw string
|
2018-11-08 12:41:07 +00:00
|
|
|
Packages []string
|
|
|
|
}
|
|
|
|
|
2018-11-12 22:38:37 +00:00
|
|
|
func (d *install) Raw() string { return strings.Join([]string{"install", d.raw}, " ") }
|
2018-11-10 12:20:10 +00:00
|
|
|
|
2018-11-08 12:41:07 +00:00
|
|
|
func (d *install) Build(_args string) error {
|
|
|
|
d.Packages = strings.Split(_args, " ")
|
2018-11-10 12:20:10 +00:00
|
|
|
d.raw = _args
|
2018-11-08 12:41:07 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
}
|
2018-11-14 19:11:07 +00:00
|
|
|
|
|
|
|
func (d install) DryRun(ctx ExecutionContext) ([]byte, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|