argbash icon indicating copy to clipboard operation
argbash copied to clipboard

ARG_OPTIONAL_ACTION without exiting

Open stellarhopper opened this issue 4 years ago • 2 comments

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.

stellarhopper avatar May 05 '21 23:05 stellarhopper

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

gdevenyi avatar May 05 '21 23:05 gdevenyi

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

stellarhopper avatar May 06 '21 00:05 stellarhopper

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.

matejak avatar Oct 03 '22 22:10 matejak