-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support for trailing '--' to indicate remaining options to be captured/forwarded verbatim #17
Comments
Argparse interprets everything after local parser = require "argparse"()
parser:flag "--wrapper-flag"
parser:argument "tail"
:args "*"
local args = parser:parse() Given
However, this will also put positional arguments before
|
Hmmm, I'm in an unfortunate position where the wrapper tool has optional positional arguments. It's tricky to distinguish if they are also in args.tail |
I've commited a change to master branch that makes local argparse = require "argparse"
local parser = argparse()
parser:argument "wrapper_argument"
:args "?"
parser:flag "--wrapper-flag"
parser:option "--"
:args "*"
:target "tool_arguments"
:argname "<arg>"
local args = parser:parse() And when given {
tool_arguments = { "--tool-flag", "a", "b", "c" },
wrapper_argument = "arg"
} Note that it's necessary to set up |
@ewmailing could you close this issue? this repository is no longer in use. |
Some wrapper tools adopt the convention of using -- as a marker to denote that all the arguments preceding that marker are for the wrapper tool, and everything after goes verbatim to the tool being wrapped.
So for example, CMake is a wrapper to different build tools. Say for example, I am currently using CMake to drive xcodebuild.
cmake --build /path/to/my/builddir -- -arch armv7s
So the --build goes to cmake, and -arch armv7s goes to xcodebuild.
Writing my own wrapper tools, I would like to do something like that, where argparse does the normal thing which I can use for my tool.
But for the --
I would like either an (ordered) array or all the remaining arguments, or a flat string. Then I could just forward that to the tool I'm calling.
Is there something already in argparse that can do this? If not, this would be a feature request.
Thank you.
The text was updated successfully, but these errors were encountered: