Skip to content
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

add support for dashed arg names and values in arg! macro #3699

Merged
merged 2 commits into from May 6, 2022

Conversation

evgeniy-terekhin
Copy link
Contributor

While migrating from clap2 to clap3 I ran into lack of support for dashed arg names and values in clap::arg! macro
meanwhile such definitions were supported but functions like arg_from_usage

Here are some examples of such problematic argument usage descriptions

[num-readers] --num-readers=<n> 'Number of reader threads'
[num-loaders] --num-loaders=<n> 'Number of loader threads'

(another problem I found is that arg! macro does not allow [flag] before any of -f or --flag but that is a different story)

so my proposed just repeats what is already done for longarg
makes it possible to wrap arg name and arg value in double quotes so that it is interpreted as literal rather than an ident

thus arg!([some_arg] "some arg") becomes possible this way arg!(["some-arg"] "some arg")
and arg!(<some_val> "some val") becomes possible this way arg!(<"some-val"> "some val")

P.S some tests provided

tests/builder/arg_name.rs Outdated Show resolved Hide resolved
@epage epage merged commit 229b44d into clap-rs:master May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants