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.
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 withsudo
.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 aflags
struct to reuse the functionApp.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 likereflect
to access the flag struct.