-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design better boolean arguments #14
Comments
After re-reading, so the only point of I can see the code being a bit cleaner using the proposed |
Good point, (any) code should read like a prose, so letting |
Hello! |
Hello, yes, it is deffinitelly planned. Stay tuned for updates! |
@matejak: Hi, will this issue be resolved? Seems like you got pretty far on your draft. Thanks |
It would also be very helpful to have a way to integrate with arithmetic condition Something like Here's the behavior of Bash arithmetic conditional construct: $ if (( 1 )); then echo yes; else echo no; fi
yes
$ if (( 0 )); then echo yes; else echo no; fi
no
$ if (( "" )); then echo yes; else echo no; fi
no
$ if (( )); then echo yes; else echo no; fi
no
$ unset foo; if (( foo )); then echo yes; else echo no; fi
no
$ foo=2; if (( foo )); then echo yes; else echo no; fi
yes
$ foo=2; if (( $foo )); then echo yes; else echo no; fi
yes
$ foo=2; if (( "$foo" )); then echo yes; else echo no; fi
yes |
Currently, the
ARG_OPTIONAL_BOOL
does not behave optimally (see #2 ).It seems to be a good idea to have more macros for switch-on, switch-off and both (as the current
ARG_OPTIONAL_BOOL
somehow attempts to).Currently,
ARG_OPTIONAL_BOOL
assumes that one wants to switch something on (using long and short option) and autogenerating long option to switch something off. This falls on its head when one wants to switch something off.Proposed behavior:
ARG_OPTIONAL_BOOL
will remain, it will autodetect whether it is in a switch-on or switch-off mode by examining the default (or the option whether it begins withno-...
, I'm not yet decided). It will use the provided long and short options for the detected mode, but it will also generate a long option for the opposite mode.ARG_OPTIONAL_BOOL(no-video, v)
would make the script accept--no-video
,-v
, that would set_arg_video
(which would beon
by default) tooff
, and--video
, that would set_arg_video
toon
, overriding possible previous occurence of-v
or--no-video
.ARG_OPTIONAL_BOOL(video, v)
would make the script accept--video
,-v
, that would set_arg_video
(which would beoff
by default) toon
, and--no-video
, that would set_arg_video
tooff
, overriding possible previous occurence of-v
or--video
.New macros would be introduced:
ARG_OPTIONAL_SWITCH_ON
will be introduced. It will accept long and short option (and no default sinceoff
will be assumed as default).ARG_OPTIONAL_SWITCH_ON(video, v)
would make the script accept--video
,-v
, that would set_arg_video
(which would beoff
by default) toon
.ARG_OPTIONAL_SWITCH_OFF
will be introduced. It will accept long and short option (and no default sinceon
will be assumed).ARG_OPTIONAL_SWITCH_OFF(no-video, v)
would make the script accept--no-video
,-v
, that would set_arg_video
(which would beon
by default) tooff
.Everybody's comments are highly appreciated!
The text was updated successfully, but these errors were encountered: