Skip to content

mapping non-trivial enum to arg group - failing with "all have default" #3711

Answered by epage
RustyJoeM asked this question in Q&A
Discussion options

You must be logged in to vote

To check, is your ideal solution #2621?

Looks like we have some debug-asserts out of order, making this more confusing. When addressed, it says from_datastore doesn't exist. This might look weird but the reason is that its from-datastore

#!/usr/bin/env -S rust-script --debug

//! ```cargo
//! [dependencies]
//! clap = { path = "../clap", features = ["derive", "debug"] }
//! ```

use clap::Parser;

#[derive(Parser, Debug)]
pub enum Args {
    #[clap(group(
        clap::ArgGroup::new("from")
            .required(true)
            .args(&["from-datastore", "from-url"]),
    ))]
    CopyConfig {
        from_datastore: Option<String>,
        from_url: Option<String>,
    },
}

fn main() {

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RustyJoeM
Comment options

Answer selected by RustyJoeM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants