Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

Add ability to derive ClapKey to use enum variants as keys #135

Open
epage opened this issue Dec 6, 2021 · 2 comments
Open

Add ability to derive ClapKey to use enum variants as keys #135

epage opened this issue Dec 6, 2021 · 2 comments

Comments

@epage
Copy link
Owner

epage commented Dec 6, 2021

Issue by kbknapp
Sunday Nov 12, 2017 at 20:12 GMT
Originally opened as clap-rs/clap#1663


See related discussion in clap-rs/clap#1104

Once the details in that issue are hashed out, we could then add support for:

#[derive(ClapKey)]
enum MyArgs {
     Foo,
     Bar,
     Baz,
}

fn main() {
    let matches = App::new("")
        /* stuff */ 
        .get_matches();
    let value = matches.value_of(MyArgs::Foo);
}
@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by Hoverbear
Sunday Nov 12, 2017 at 20:28 GMT


Should this be part of initial publish?

@epage
Copy link
Owner Author

epage commented Dec 6, 2021

Comment by kbknapp
Sunday Nov 12, 2017 at 20:44 GMT


This brings up a bigger point. Should clap-derives be usable on clap 2.x?

I'm leaning yes, because what you've done already works today. I also think we should be pushing towards a clap-derives which works on clap 3.x which this issue is aimed at.

So I think we need to find a way to differentiate between these two branches.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant