From ead0c7913995ed74b02290edbba0ea750bf33480 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Wed, 30 Nov 2022 19:33:40 -0800 Subject: [PATCH] Use correct verb when prompting user to choose packages --- build.go | 4 ++-- info.go | 2 +- install.go | 6 +++--- internal/repos/pull.go | 3 +++ repo.go | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/build.go b/build.go index 879f2ba..0981614 100644 --- a/build.go +++ b/build.go @@ -227,7 +227,7 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st } log.Info("Installing build dependencies").Send() - installPkgs(ctx, flattenFoundPkgs(found), notFound, mgr) + installPkgs(ctx, flattenFoundPkgs(found, "install"), notFound, mgr) } var builtDeps, builtNames, repoDeps []string @@ -239,7 +239,7 @@ func buildPackage(ctx context.Context, script string, mgr manager.Manager) ([]st return nil, nil, err } - scripts := getScriptPaths(flattenFoundPkgs(found)) + scripts := getScriptPaths(flattenFoundPkgs(found, "install")) for _, script := range scripts { pkgPaths, pkgNames, err := buildPackage(ctx, script, mgr) if err != nil { diff --git a/info.go b/info.go index 74e2762..14a02c2 100644 --- a/info.go +++ b/info.go @@ -44,7 +44,7 @@ func infoCmd(c *cli.Context) error { os.Exit(1) } - pkgs := flattenFoundPkgs(found) + pkgs := flattenFoundPkgs(found, "show") for _, pkg := range pkgs { err = yaml.NewEncoder(os.Stdout).Encode(pkg) diff --git a/install.go b/install.go index 6dbae7a..dad49d6 100644 --- a/install.go +++ b/install.go @@ -52,7 +52,7 @@ func installCmd(c *cli.Context) error { 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 } @@ -76,11 +76,11 @@ func getScriptPaths(pkgs []db.Package) []string { 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 for _, pkgs := range found { if len(pkgs) > 1 { - choices, err := pkgPrompt(pkgs) + choices, err := pkgPrompt(pkgs, verb) if err != nil { log.Fatal("Error prompting for choice of package").Send() } diff --git a/internal/repos/pull.go b/internal/repos/pull.go index 4a50814..23d608e 100644 --- a/internal/repos/pull.go +++ b/internal/repos/pull.go @@ -28,6 +28,9 @@ import ( "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 { for _, repo := range repos { repoURL, err := url.Parse(repo.URL) diff --git a/repo.go b/repo.go index bc4b4eb..62ca407 100644 --- a/repo.go +++ b/repo.go @@ -122,7 +122,7 @@ func refreshCmd(c *cli.Context) error { 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)) for i, option := range options { names[i] = option.Repository + "/" + option.Name + " " + option.Version @@ -130,7 +130,7 @@ func pkgPrompt(options []db.Package) ([]db.Package, error) { prompt := &survey.MultiSelect{ Options: names, - Message: "Choose which package(s) to install", + Message: "Choose which package(s) to " + verb, } var choices []int