Closed sgallagher closed 7 years ago
Hello, you are right, the current handling of defaults is not documented. I slightly prefer this behavior for its consistency --- now, adding script arguments to the command-line makes the script core functionality believe that it got more arguments, or some of the existing arguments were overriden (or both). Throwing away defaults from repeated arguments would lead to the effect that adding one argument would remove multiple values. So I plan to fix this by properly documenting the existing behavior; however, do you have user stories suggesting that the alternative behavior is more useful?
Well, in my particular case, I was attempting to create an option that would tell a script to operate on multiple architectures of sample data. I wanted to be able to set a default that it would run on all the architectures that we support, but to be able to set a reduced number (possibly only one) at the command-line, primarily for debugging (so I wouldn't have to wait for the script to process through all of them at once).
Perhaps when using ARG_OPTIONAL_REPEATED
, it could also generate a --clear-foo
flag that would allow you to empty the default list explicitly and then append to it with further --foo
arguments?
If you are curious, the example I was working on is here: https://github.com/sgallagher/baseruntime-package-lists/blob/master/download_repo.sh#L9
For now, I'm leaving it blank and adding the values I need at the command line. But I'd prefer to be able to set the defaults.
You have a good point, I will think about it.
The issue is technically fixed (by added documentation), but see #13 for the proper fix.
The documentation for ARG_OPTIONAL_REPEATED reads:
The other options for argbash will supersede their defaults, but the effect of using the default option in ARG_OPTIONAL_REPEATED means that this set of values will always be present in the resulting list and that the arguments specified at the command-line merely supplement them.
Either the documentation should reflect this behavior or it should be changed to behave more similarly to the other options.