devops-works / binenv

One binary to rule them all. Manage all those pesky binaries (kubectl, helm, terraform, ...) easily.
MIT License
367 stars 44 forks source link

feature: Add expand command #187

Closed semoac closed 2 years ago

semoac commented 2 years ago

I'm facing scenarios where I need to get the full path of a binary (like when using which) to use inside bash scripting or in conjunction with sudo.

I noticed that something like this was requests on this issue, so I write a little proposal.

This PR implement the expand command by adding a flags struct to reuse the function App.Execute while slightly changing its behavior.

About the implementation itself, while witting a new function is easier, having duplicate code may be bad for the future.

As for the flags struct, I use a map of functions that could hold custom logic to manage the lifecycle of the flags. This way, new flag that may flip other flags or that may require extra validation before changing can be implemented without much effort.

If you think this feature make sense but don't like the implementation, let me know! Maybe I can propose something simpler, like copy-and-pasting the Excute logic into a separate function or using something like reflect to access the flag struct.

leucos commented 2 years ago

Sorry to make you wait; I lag a lot. Will handle this asap.

leucos commented 2 years ago

This is awesome. Sorry for the wait :pray:

leucos commented 2 years ago

Enjoy https://github.com/devops-works/binenv/releases/tag/v0.18.0