-
-
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
Multiple Positional Arguments with Defaults #99
Comments
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 So you can pass either one positional argument (which is interpreted as 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
The text was updated successfully, but these errors were encountered: