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

Example using clap v3 derive #4

Open
thesurlydev opened this issue Jan 30, 2022 · 5 comments
Open

Example using clap v3 derive #4

thesurlydev opened this issue Jan 30, 2022 · 5 comments

Comments

@thesurlydev
Copy link

Could you provide an example of how to integrate with a clap v3 derive app? I'd like to be able to have configuration file and/or environment variables provide defaults, then allow overrides via clap command line args.

@nyurik
Copy link

nyurik commented May 27, 2022

@storyfeet when you have a moment, this would greatly help with getting started! Also, the clap_app! has been deprecated by clap v3, so it is bit confusing how use clap derive. Thx!

@storyfeet
Copy link
Owner

Hi, Sorry, I don't know why I didn't see this before, I do have a watch on the repo.

I'm looking at the new clap with derive now, and I don't think clap_conf works with it as things stand, It'll take some reading to work out how to make it work.

@nyurik
Copy link

nyurik commented Jun 5, 2022

Thanks @storyfeet ! You may also be interested in clap-rs/clap#2763 discussion and a more specific clap-rs/clap#1206 issue.

@storyfeet
Copy link
Owner

storyfeet commented Jun 5, 2022

The problem working with the derive is the type it creates does not have a general "get" method, instead each required property ie "name" holds an option<T> which is great making sure types are handled correctly,

but clap_conf relies on having a get general mechanism for the Getter Trait which is used to combine the items.

I believe this could also be derived, but if I'm honest I'm in no hurry to start learning to write these kinds of macros. (feel free to have a go) But by the time you've done that, you might as well just use the "builder" as it loses the type information to go back to a string return anyway.

@nyurik
Copy link

nyurik commented Aug 15, 2022

Update: clap-rs/clap#1206 has just been fixed, so you can iterate over args now.

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

No branches or pull requests

3 participants