From 00e1249bd86fa32c5cde053c8f19afb6efd1c95f Mon Sep 17 00:00:00 2001 From: Marcos Nils <1578458+marcosnils@users.noreply.github.com> Date: Tue, 18 Jul 2023 22:29:27 -0300 Subject: [PATCH] add ability to specify binaries for ensure command (#168) fixes #167 Signed-off-by: Marcos Lilljedahl --- cmd/ensure.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cmd/ensure.go b/cmd/ensure.go index cea38c2..018a6b1 100644 --- a/cmd/ensure.go +++ b/cmd/ensure.go @@ -19,15 +19,27 @@ func newEnsureCmd() *ensureCmd { root := &ensureCmd{} // nolint: dupl cmd := &cobra.Command{ - Use: "ensure", + Use: "ensure [binary_path]...", Aliases: []string{"e"}, Short: "Ensures that all binaries listed in the configuration are present", SilenceUsage: true, - Args: cobra.MaximumNArgs(0), SilenceErrors: true, RunE: func(cmd *cobra.Command, args []string) error { cfg := config.Get() - binsToProcess := cfg.Bins + binsToProcess := map[string]*config.Binary{} + + // Update specific binaries + if len(args) > 0 { + for _, a := range args { + bin, err := getBinPath(a) + if err != nil { + return err + } + binsToProcess[bin] = cfg.Bins[bin] + } + } else { + binsToProcess = cfg.Bins + } // TODO: code smell here, this pretty much does // the same thing as install logic. Refactor to