Open EdwardOst opened 5 years ago
This is a tricky feature request. Imagine that the script accepts two arguments, both of them have default. You supply one. The question is: Which one has been supplied? The first one, or the last one?
since they are positional it would be the first one. I realize that I can do this with ARG_POSITIONAL_INF but the parameters are not named.
Your answer sounds reasonable. I will think of this - the feature is not so complicated to implement, but it will open a lot of possibilities, and the code has to be tested thoroughly, so it won't break in the future.
I second this feature request.
In my particular case I want a command similar to man, which has the usage man <options go here> [section] name
So you can pass either one positional argument (which is interpreted as name
) or two (which are interpreted as section
first and then name
).
I was thinking about implementing this with an empty default for section, indicating that it is optional:
# ARG_POSITIONAL_SINGLE([section],[],[""])
# ARG_POSITIONAL_SINGLE([name])
But as @EdwardOst points out, you can't have positional arguments with defaults at the beginning.
Now, it works fine the other way around, but I would prefer to have it this way to share muscle memory with related commands.
Feature Request: Argbash allows defaults for positional arguments, but in practice it can only be applied to the first positional argument. Many scripts have multiple parameters which have defaults. All such positional optional parameters are necessarily at the end of the signature. Intelligent defaults is a good practice in general. Could this be supported in a future version of Argbash?
Example
could support
myscript myscript mybucket myscript mybucket my/folder/key