StructConf

Combine argument parsing with a config file at compile time. Build Status docs.rs version

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, and developed to be used in Vidify. Example:

```rust use clap::App; use structconf::StructConf;

[derive(Debug, StructConf)]

struct Config { // Option available in the config file and the arguments #[conf(help = "description for the argument parser.")] pub default: i32, // Specify where the options are available. #[conf(nofile)] pub argsopt: u8, #[conf(noshort, nolong)] pub confopt: Option, #[conf(noshort, nolong, nofile)] pub ignored: bool, // Customize the names #[conf(short = "x", long = "renamed-opt", file = "myopt", help = "custom names.")] pub renamed: String, // Inverse arguments #[conf(short = "n", long = "nopancakes", help = "disable pancakes.")] pub pancakes: bool, // Custom default values #[conf(default = "123.45")] pub floating: f64, }

pub fn main() { let app = App::new("demo"); let conf = Config::parse(app, "config.ini"); println!("Parsed config: {:#?}", conf); } ```

Read the docs for more details on how to use StructConf.