Skip to content

Commit

Permalink
Allow to update multiple binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosnils committed May 22, 2021
1 parent b3b3596 commit 74bf928
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@ func newUpdateCmd() *updateCmd {
Aliases: []string{"u"},
Short: "Updates one or multiple binaries managed by bin",
SilenceUsage: true,
Args: cobra.MaximumNArgs(1),
SilenceErrors: true,
RunE: func(cmd *cobra.Command, args []string) error {
// TODO add support to update from a specific URL.
// This allows to update binares from a repo that contains
// multiple tags for different binaries

var bin string
if len(args) > 0 {
bin = args[0]
}

// TODO update should check all binaries with a
// certain configured parallelism (default 10, can be changed with -p) and report
// which binarines could be potentially upgraded.
Expand All @@ -54,16 +48,21 @@ func newUpdateCmd() *updateCmd {

toUpdate := map[*updateInfo]*config.Binary{}
cfg := config.Get()
binsToProcess := cfg.Bins
binsToProcess := map[string]*config.Binary{}

// Update single binary
if bin != "" {
bin, err := getBinPath(bin)
if err != nil {
return err
// 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]
}
binsToProcess = map[string]*config.Binary{bin: cfg.Bins[bin]}
} else {
binsToProcess = cfg.Bins
}

for _, b := range binsToProcess {
p, err := providers.New(b.URL, b.Provider)
if err != nil {
Expand Down

0 comments on commit 74bf928

Please sign in to comment.