mirror of
https://github.com/OMGeeky/confique.git
synced 2026-02-23 15:38:30 +01:00
Add Source trait and implement it for files (TOML and YAML for now)
This commit is contained in:
2
examples/files/etc/simple.yaml
Normal file
2
examples/files/etc/simple.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
http:
|
||||
port: 4321
|
||||
2
examples/files/simple.toml
Normal file
2
examples/files/simple.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[cat]
|
||||
foo = "yes"
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::net::IpAddr;
|
||||
use confique::{Config, Partial};
|
||||
use std::{net::IpAddr, path::Path};
|
||||
use confique::Config;
|
||||
|
||||
#[derive(Debug, Config)]
|
||||
struct Conf {
|
||||
@@ -26,6 +26,13 @@ struct Cat {
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
println!("{:#?}", Conf::from_partial(<Conf as Config>::Partial::default_values()));
|
||||
fn main() -> Result<(), anyhow::Error> {
|
||||
let r = Conf::from_sources(&[
|
||||
&Path::new("examples/files/simple.toml"),
|
||||
&Path::new("examples/files/etc/simple.yaml"),
|
||||
])?;
|
||||
|
||||
println!("{:#?}", r);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user