You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.
use clap::Clap;#[derive(Debug,Clap)]structOpts{#[clap(long, conflicts_with = "hello-world")]// I thought it should be hello_worldone:Option<String>,#[clap(long)]hello_world:Option<String>,}fnmain(){Opts::parse();}
It is a bit confusing that conflicts_with only work with the transformed string and the issue is that it only errors on runtime, during compile-time there is no error saying that that is incorrect. Can it be checked during compile-time? It is also confusing that I put hello_world in the struct but I need to use hello-world in the option.
Steps to reproduce the bug with the above code
cargo run
Actual Behaviour
thread 'main' panicked at 'Argument or group 'hello_world' specified in 'conflicts_with*' for 'one' does not exist', /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-3.0.0-beta.2/src/build/app/debug_asserts.rs:158:13
Expected Behaviour
First, using hello_world should work instead of hello-world.
Second, it should error during compile-time.
Additional Context
No response
Debug Output
error[E0432]: unresolved import `clap::Clap`
--> src/main.rs:1:5
|
1 | use clap::Clap;
| ^^^^^^^^^^ no `Clap` in the root
error: cannot determine resolution for the derive macro `Clap`
--> src/main.rs:3:17
|
3 | #[derive(Debug, Clap)]
| ^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error: cannot find attribute `clap` in this scope
--> src/main.rs:5:7
|
5 | #[clap(long, conflicts_with = "hello_world")] // I thought it should be helllo_world
| ^^^^
error: cannot find attribute `clap` in this scope
--> src/main.rs:7:7
|
7 | #[clap(long)]
| ^^^^
error[E0599]: no function or associated item named `parse` found for struct `Opts` in the current scope
--> src/main.rs:12:11
|
4 | struct Opts {
| ----------- function or associated item `parse` not found for this
...
12 | Opts::parse();
| ^^^^^ function or associated item not found in `Opts`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `hello`
To learn more, run the command again with --verbose.
The text was updated successfully, but these errors were encountered:
Structopt passes cased_name to Arg::with_name, so I think its "broken" there too. So by leaving this, we don't introduce any more of a migration problem than if we change it now.
Comment by epage Saturday Oct 09, 2021 at 10:27 GMT
I am not exactly sure what the expected behaviour should be.
As a user solely of clap_derive, I do not know of the existence of the "name" field, just what my variables are. I have a variable named hello_world, I assume when working with conflicts_with, I would pass in that variable name.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Issue by pickfire
Sunday May 09, 2021 at 13:47 GMT
Originally opened as clap-rs/clap#2475
Please complete the following tasks
Rust Version
rustc 1.52.0 (88f19c6da 2021-05-03)
Clap Version
3.0.0-beta.2
Minimal reproducible code
It is a bit confusing that conflicts_with only work with the transformed string and the issue is that it only errors on runtime, during compile-time there is no error saying that that is incorrect. Can it be checked during compile-time? It is also confusing that I put
hello_world
in the struct but I need to usehello-world
in the option.Steps to reproduce the bug with the above code
cargo run
Actual Behaviour
Expected Behaviour
First, using
hello_world
should work instead ofhello-world
.Second, it should error during compile-time.
Additional Context
No response
Debug Output
The text was updated successfully, but these errors were encountered: