-
Notifications
You must be signed in to change notification settings - Fork 62
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
RFC-lite: Possible API design & scope #2
Conversation
Sorry it took me two weeks to get back to this :) The API looks okay. Simple, but we can always add stuff to reduce boilerplate later on ( So, what I want to have is a crate that basically solves configuration (for CLIs, at least). It should offer a great API to define the structure of you app config, but then only give you one thing: Commenting on the proposed API like it's for a
Probably. I don't think we can easily add derives from another crate in our derive. (Worth a try, though!)
Delete/cleanup
Rust folks like TOML
Adding adaptors add support for more things that use serde should be possible. 3rd-party-crates would be cool, otherwise as feature flags.
No idea. I'd go with "no" for now. |
@Dylan-DPC actually I'm not sure if it is the right direction. I'm currently working on something between platform-config and config, that is a trait
with two custom derives:
This way I think provides better separation between app configuration and command line args, more explicitness and less magic. I'm only trying to figure out if there is a way to use current config crate without any modifcations but I think it provides different mechanism - it stores |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally looked at this. I'm still curious to see #3 (goals / non-goals) fleshed out some.
#[macro_use] extern crate confy; | ||
|
||
#[derive(Confy)] | ||
struct MyConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a derive attr here could remove the need to pass "my_app"
below. So something like
#[derive(Confy)]
#[confy(name="my_app")]
strucy MyConfig {
// ... fields
}
and later, just let cfg: MyConfig = confy::load()?
and confy::create(MyConfig { /* ... */ })
etc.
@synek317 The entire point of this crate was to create a "magic" solution that people can just drop into their application with very little effort required. The idea of basing it all on some common traits is an interesting one though, essentially allowing easier inter-op between different crates. But for the end-user of @kamalmarhubi Good point, we could have a look at what flags people might want to provide and then add them to the proc-macro |
In my wishlist I have the need for good config override: global config -> local config -> args -(is_empthy)> default
The support for file parsing should be features-driven like stager? |
I'm gonna close this PR for now, as the API described in the proposal is almost implemented. I've turned all of the questions/ discussion points into issues so we can talk about the subjects there. #4 – Multi-part configurations |
This is a small example of how such a crate could work. There are a lot of open questions though.
The baseline for the design of this config crate is however that a user shouldn't have to worry about what platform they're running on and should be designed with the mantra of "Just give me a config" in mind!
(Code Example)
Scope
dotenv
?Implementation details
serialize
/deserialize
, do we have to explicitly declare that?And above all: your thoughts?