matejak / argbash

Bash argument parsing code generator
Other
1.39k stars 63 forks source link

Perform argbash arg parsing for bash functions #183

Open DryHumorInDC opened 1 year ago

DryHumorInDC commented 1 year ago

I love argbash for parsing arguments parse via an interactive shell. In addition, I would like to have this same functionality for user-defined functions.

mbeko commented 11 months ago

I also have a use case for this.

I often write simple tools or REST API clients as functions in a script. Whenever I need to use that functionality, I source the script and call the functions as needed. Some functions have many optional parameters, so using the positional argument variables for these gets quickly unwieldy, e.g. if you only want to set the last one of six optional parameters, you have to provide values for the other five.

Especially with multiplle small functions, it doesn't seem to make much sense to put each of them in a file, so I was wondering if it's feasible to add the Argbash functionality to functions.

However, I understand if this won't be added because even more code would be generated that bloats the script, or because it would be too much work to implement it properly such that there are no name conflicts.