Crates.io | structconf |
lib.rs | structconf |
version | 0.5.0 |
source | src |
created_at | 2020-07-09 23:54:21.117813 |
updated_at | 2022-01-04 21:09:38.427361 |
description | Combine clap and rust-ini into a single procedural macro |
homepage | https://github.com/marioortizmanero/structconf |
repository | https://github.com/marioortizmanero/structconf |
max_upload_size | |
id | 263068 |
size | 58,273 |
StructConf is a small derive macro that allows you to combine argument parsing from clap and config file parsing from rust-ini at compile time. It's inspired by the argument parser structopt.
StructConf aims to be relatively small and simple. Here are its current selling points:
Option
.Small example:
use structconf::{clap, StructConf};
#[derive(Debug, StructConf)]
struct ServerConfig {
#[conf(help = "The public key")]
pub public_key: String,
#[conf(no_file, long = "your-secret", help = "Your secret API key")]
pub secret_key: String,
#[conf(default = "100", help = "timeout in seconds")]
pub timeout: i32,
}
pub fn main() {
let app = clap::App::new("demo");
let conf = ServerConfig::parse(app, "config.ini");
println!("Parsed config: {:#?}", conf);
}
For more details on how to use Structconf, read the docs and check out the examples.