Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability to specify binaries for ensure command #168

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions cmd/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down