Skip to content

Commit 73796ae

Browse files
Adjust README
1 parent d1a62e4 commit 73796ae

File tree

1 file changed

+98
-13
lines changed

1 file changed

+98
-13
lines changed

README.md

Lines changed: 98 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,28 @@ Confique is a rather light-weight library that helps with configuration manageme
1313
- **Layered configuration**: you can load from and then merge multiple sources of configuration.
1414
- **Load config values from**:
1515
- Environment variables
16-
- Files: TOML & YAML
17-
- Anything with a `serde` Deserializer (built-in support for more formats coming soon)
16+
- Files: [TOML](https://toml.io/), [YAML](https://yaml.org/), and [JSON5](https://json5.org/)
17+
- Anything with a `serde` Deserializer
1818
- **Based on `serde`**: less code in `confique` (more light-weight) and access to a huge ecosystem of high quality parsers.
19-
- Easily generate configuration "templates" to describe all available config values to your users.
19+
- **Easily generate configuration "templates"**: describe all available config values to your users without repeating yourself.
2020

2121

2222
## Simple example
2323

2424
```rust
25-
use std::path::PathBuf;
25+
use std::{net::IpAddr, path::PathBuf};
2626
use confique::Config;
2727

2828

2929
#[derive(Config)]
3030
struct Conf {
31-
#[config(env = "EXAMPLE_APP_USERNAME")]
32-
username: String,
31+
/// Port to listen on.
32+
#[config(env = "PORT", default = 8080)]
33+
port: u16,
3334

34-
#[config(env = "EXAMPLE_APP_BUFFER_SIZE", default = 4096)]
35-
buffer_size: u32,
35+
/// Bind address.
36+
#[config(default = "127.0.0.1")]
37+
address: IpAddr,
3638

3739
#[config(nested)]
3840
log: LogConf,
@@ -44,6 +46,9 @@ struct LogConf {
4446
stdout: bool,
4547

4648
file: Option<PathBuf>,
49+
50+
#[config(default = ["debug"])]
51+
ignored_modules: Vec<String>,
4752
}
4853

4954

@@ -56,10 +61,90 @@ let config = Conf::builder()
5661

5762
See [**the documentation**](https://docs.rs/confique) for more information.
5863

64+
### Configuration Template
65+
66+
With the above example, you can automatically generate a configuration template:
67+
a file in a chosen format that lists all values with their description, default values, and env values.
68+
69+
<table>
70+
<tr>
71+
<td><code>toml::template::&lt;Conf&gt;()</code></td>
72+
<td><code>yaml::template::&lt;Conf&gt;()</code></td>
73+
<td><code>json5::template::&lt;Conf&gt;()</code></td>
74+
</tr>
75+
<tr>
76+
<td>
77+
78+
```toml
79+
# Port to listen on.
80+
#
81+
# Can also be specified via
82+
# environment variable `PORT`.
83+
#
84+
# Default value: 8080
85+
#port = 8080
86+
87+
# Bind address.
88+
#
89+
# Default value: "127.0.0.1"
90+
#address = "127.0.0.1"
91+
92+
[log]
93+
# <omitted>
94+
```
5995

60-
## Comparison with other libraries/solutions
96+
</td>
97+
<td>
98+
99+
```yaml
100+
# Port to listen on.
101+
#
102+
# Can also be specified via
103+
# environment variable `PORT`.
104+
#
105+
# Default value: 8080
106+
#port: 8080
107+
108+
# Bind address.
109+
#
110+
# Default value: 127.0.0.1
111+
#address: 127.0.0.1
112+
113+
log:
114+
# <omitted>
115+
```
116+
117+
</td>
118+
<td>
119+
120+
```json5
121+
{
122+
// Port to listen on.
123+
//
124+
// Can also be specified via
125+
// environment variable `PORT`.
126+
//
127+
// Default value: 8080
128+
//port: 8080,
129+
130+
// Bind address.
131+
//
132+
// Default value: "127.0.0.1"
133+
//address: "127.0.0.1",
134+
135+
log: {
136+
// <omitted>
137+
},
138+
}
139+
```
140+
141+
</td>
142+
</tr>
143+
</table>
61144

62-
Obviously, all other libraries are more mature than confique.
145+
<sup>(Note: The "environment variable" sentence is on a single line; I just split it into two lines for readability in this README.)</sup>
146+
147+
## Comparison with other libraries/solutions
63148

64149
### [`config`](https://crates.io/crates/config)
65150

@@ -86,9 +171,9 @@ With `confique` you also get some other handy helpers.
86171

87172
## Status of this project
88173

89-
Confique is still a very young project.
90-
There are lots of features and improvements already planned.
91-
I'm developing this library alongside a web project that uses it.
174+
There is still some design space to explore and there are certainly still many features one could add.
175+
However, the core interface (the derive macro and the core traits) probably won't change a lot anymore.
176+
Confique is used by a web project (that's already used in production) which I'm developing alongside of confique.
92177

93178

94179
<br />

0 commit comments

Comments
 (0)