-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Variant of allow_hyphen_values that treats --
like a regular value
#5055
Comments
Generally, a (sub)command will have some of its own arguments besides those that get forwarded. When it doesn't, external subcommands might be more appropriate (though custom help output might be needed to get quality output). Maybe there are things we can do for that help output... When it does, the general approach is what you did with I'm assuming the request here is a way to completely forward a command with good help output. At this point, it might be good to get further clarification on the use case before diving more into potential solutions. |
Yes. I would like it to do that, and then stop parsing on the first unexpected token and put all the rest into the trailing argument.
Yes I know I am losing generality here. For instance
Basically: having a script wrap another command (that already takes |
I'm interested in this as well. I have a subcommand that takes a few options and then the name and arguments for another program. It's fine if program names starting with |
Thanks for the explanations! The part i find messy here is that the way the command wrapping is being done here is trying to be transparent to the user but it requires all new arguments to be placed first. That only weighs in depending on how the options look. In this case, I think the way this makes the most sense is the ability to turn off escaping, so |
As a use case: a lot of unix tools can work with # as a placeholder for the command_name
sh -c 'echo $0 $1' -- arg
#> -- arg
echo --
#> -- However with clap now in projects such as
the hyphen brush -c 'echo $0 $1' -- arg
#> arg
uecho --
#>
|
- Added functions `try_parse_known` and `parse_known` for splitting arguments into `before hyphen` and `hyphen and after hyphen` - This approach allows manually deciding what to do with `--` and the remaining arguments Fixes: - main CommandLineArgs - EchoCommand Clap issue: clap-rs/clap#5055
- Added functions `try_parse_known` and `parse_known` for splitting arguments into `before hyphen` and `hyphen and after hyphen` - This approach allows manually deciding what to do with `--` and the remaining arguments Fixes: - main CommandLineArgs - EchoCommand Clap issue: clap-rs/clap#5055
- Added functions `try_parse_known` and `parse_known` for splitting arguments into `before hyphen` and `hyphen and after hyphen` - This approach allows manually deciding what to do with `--` and the remaining arguments Fixes: - main CommandLineArgs - EchoCommand Clap issue: clap-rs/clap#5055
- Added functions `try_parse_known` and `parse_known` for splitting arguments into `before hyphen` and `hyphen and after hyphen` - This approach allows manually deciding what to do with `--` and the remaining arguments Fixes: - main CommandLineArgs - EchoCommand Clap issue: clap-rs/clap#5055
- Added functions `try_parse_known` and `parse_known` for splitting arguments into `before hyphen` and `hyphen and after hyphen` - This approach allows manually deciding what to do with `--` and the remaining arguments Fixes: - main CommandLineArgs - EchoCommand Clap issue: clap-rs/clap#5055
- clap does not handle `--` as an argument but rather as a separator so we need additional processing for passing `--` as an operand to a `-c` script. This is because Posix interprets `--` as an operand. The first argument in `-c` is the name of the command and can be `--` just fine. See: Posix about sh https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02 test: tests for command line argument handling feat: helper functions to deal with clap's limitation handling `--` - Added functions `try_parse_known` and `parse_known` for splitting arguments into `before hyphen` and `hyphen and after hyphen` - This approach allows manually deciding what to do with `--` and the remaining arguments Fixes: - main CommandLineArgs - EchoCommand Clap issue: clap-rs/clap#5055 fix: clippy lints
Please complete the following tasks
Clap Version
4.2.7
Describe your use case
I would like to write a program with various subcommands that mostly wrap various
cargo
commands. So for instance./miri clippy <args>
should just forward all<args>
completely unaltered to the underlyingcargo clippy
invocations. I was hoping that enablingtrailing_var_arg
andallow_hyphen_values
achieves this, but sadly that is not the case:./miri clippy -- -D warnings
leads to-D warnings
being forwarded, the leading--
is dropped.Interestingly,
./miri clippy --all-features -- -D warnings
behaves correctly, and--
ends up as part of the arguments. Only a leading--
is not handled as desired.Describe the solution you'd like
Some way to indicate that an argument should just consume all remaining tokens into a
Vec<String>
would be great. I first thought maybe that's whatraw
does, but raw seems to actually require a--
(and then strips it) so that doesn't help.Alternatives, if applicable
No response
Additional Context
This is basically re-opening #1236.
The text was updated successfully, but these errors were encountered: