Use correct verb when prompting user to choose packages
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2022-11-30 19:33:40 -08:00
parent 1377ef1bc9
commit ead0c79139
5 changed files with 11 additions and 8 deletions

View File

@ -227,7 +227,7 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st
} }
log.Info("Installing build dependencies").Send() log.Info("Installing build dependencies").Send()
installPkgs(ctx, flattenFoundPkgs(found), notFound, mgr) installPkgs(ctx, flattenFoundPkgs(found, "install"), notFound, mgr)
} }
var builtDeps, builtNames, repoDeps []string var builtDeps, builtNames, repoDeps []string
@ -239,7 +239,7 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st
return nil, nil, err return nil, nil, err
} }
scripts := getScriptPaths(flattenFoundPkgs(found)) scripts := getScriptPaths(flattenFoundPkgs(found, "install"))
for _, script := range scripts { for _, script := range scripts {
pkgPaths, pkgNames, err := buildPackage(ctx, script, mgr) pkgPaths, pkgNames, err := buildPackage(ctx, script, mgr)
if err != nil { if err != nil {

View File

@ -44,7 +44,7 @@ func infoCmd(c *cli.Context) error {
os.Exit(1) os.Exit(1)
} }
pkgs := flattenFoundPkgs(found) pkgs := flattenFoundPkgs(found, "show")
for _, pkg := range pkgs { for _, pkg := range pkgs {
err = yaml.NewEncoder(os.Stdout).Encode(pkg) err = yaml.NewEncoder(os.Stdout).Encode(pkg)

View File

@ -52,7 +52,7 @@ func installCmd(c *cli.Context) error {
log.Fatal("Error finding packages").Err(err).Send() log.Fatal("Error finding packages").Err(err).Send()
} }
installPkgs(c.Context, flattenFoundPkgs(found), notFound, mgr) installPkgs(c.Context, flattenFoundPkgs(found, "install"), notFound, mgr)
return nil return nil
} }
@ -76,11 +76,11 @@ func getScriptPaths(pkgs []db.Package) []string {
return scripts return scripts
} }
func flattenFoundPkgs(found map[string][]db.Package) []db.Package { func flattenFoundPkgs(found map[string][]db.Package, verb string) []db.Package {
var outPkgs []db.Package var outPkgs []db.Package
for _, pkgs := range found { for _, pkgs := range found {
if len(pkgs) > 1 { if len(pkgs) > 1 {
choices, err := pkgPrompt(pkgs) choices, err := pkgPrompt(pkgs, verb)
if err != nil { if err != nil {
log.Fatal("Error prompting for choice of package").Send() log.Fatal("Error prompting for choice of package").Send()
} }

View File

@ -28,6 +28,9 @@ import (
"mvdan.cc/sh/v3/syntax" "mvdan.cc/sh/v3/syntax"
) )
// Pull pulls the provided repositories. If a repo doesn't exist, it will be cloned
// and its packages will be written to the DB. If it does exist, it will be pulled.
// In this case, only changed packages will be processed.
func Pull(ctx context.Context, gdb *genji.DB, repos []types.Repo) error { func Pull(ctx context.Context, gdb *genji.DB, repos []types.Repo) error {
for _, repo := range repos { for _, repo := range repos {
repoURL, err := url.Parse(repo.URL) repoURL, err := url.Parse(repo.URL)

View File

@ -122,7 +122,7 @@ func refreshCmd(c *cli.Context) error {
return nil return nil
} }
func pkgPrompt(options []db.Package) ([]db.Package, error) { func pkgPrompt(options []db.Package, verb string) ([]db.Package, error) {
names := make([]string, len(options)) names := make([]string, len(options))
for i, option := range options { for i, option := range options {
names[i] = option.Repository + "/" + option.Name + " " + option.Version names[i] = option.Repository + "/" + option.Name + " " + option.Version
@ -130,7 +130,7 @@ func pkgPrompt(options []db.Package) ([]db.Package, error) {
prompt := &survey.MultiSelect{ prompt := &survey.MultiSelect{
Options: names, Options: names,
Message: "Choose which package(s) to install", Message: "Choose which package(s) to " + verb,
} }
var choices []int var choices []int