matejak / argbash

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

ARG_OPTIONAL_ACTION without exiting #153

Closed stellarhopper closed 1 year ago

stellarhopper commented 3 years ago

It would be nice to have a version of ARG_OPTIONAL_ACTION that executes ACTION, but continues with the script instead of exiting.

My use case for this would be something like: ARG_OPTIONAL_ACTION([debug], [d], [Debug script problems (enables set -x)], [set -x]) i.e. this would set flags or so if supplied, but otherwise continue the script as normal.

I'm assuming this would need a new API - maybe ARG_OPTIONAL_ACTION_CONTINUE? I can try implementing it if this sounds reasonable.

gdevenyi commented 3 years ago

Why not just make debug a boolean and do this: https://github.com/CoBrALab/iterativeN4_multispectral/blob/master/iterativeN4_multispectral.sh#L267-L272

stellarhopper commented 3 years ago

@gdevenyi yes that is my workaround currently. But having a continu-able action would make some of that a lot cleaner.

matejak commented 1 year ago

Closing this for the reason outined by @gdevenyi. The idea behind Argbash is to do the simple things in a simple way, standard things in a somewhat simple way, and still let users do more complex things on top of what Argbash produces. I think that bool arguments are fine, sorry for still generating the --no- negations, hopefully that won't be in Argbash forever.