diff options
author | Daniel Schadt <kingdread@gmx.de> | 2019-12-14 03:23:46 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2019-12-14 03:23:46 +0100 |
commit | 97f2678563e6ca997ea33d7befe38ab2acfa01a9 (patch) | |
tree | d0ee757fcc01555362ec4578dafbf946034c0e64 /src/main.rs | |
parent | 2aef95f62788163b789fae92b5a6546b2413d9e4 (diff) | |
download | kondou-97f2678563e6ca997ea33d7befe38ab2acfa01a9.tar.gz kondou-97f2678563e6ca997ea33d7befe38ab2acfa01a9.tar.bz2 kondou-97f2678563e6ca997ea33d7befe38ab2acfa01a9.zip |
add preliminary support for user configurations
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 395e683..f990319 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ extern crate num_traits; extern crate reqwest; extern crate rusttype; extern crate termcolor; +extern crate toml; extern crate xdg; #[macro_use] extern crate lazy_static; @@ -33,6 +34,7 @@ mod bt; mod cache; mod output; mod render; +mod useropts; use clap::{App, Arg, ArgMatches}; @@ -345,6 +347,12 @@ fn run() -> MainResult<()> { .default_value("buildtemplate.png") .takes_value(true), ) + .arg( + Arg::with_name("config") + .help("Specifies the render option file.") + .long("config") + .takes_value(true), + ) .get_matches(); let mut api = Api::new(cache::FileCache::new()); @@ -360,7 +368,13 @@ fn run() -> MainResult<()> { println!("{}", build.chatlink()); } - let mut renderer = render::Renderer::new(&mut api, Default::default()); + let render_options = if let Some(config_path) = matches.value_of("config") { + useropts::load_file(config_path)? + } else { + Default::default() + }; + + let mut renderer = render::Renderer::new(&mut api, render_options); match renderer.render_buildtemplate(&build) { Ok(img) => { let filename = matches.value_of("outfile").unwrap(); @@ -368,7 +382,7 @@ fn run() -> MainResult<()> { if !matches.is_present("quiet") { println!("Image saved in {}", filename); } - }, + } Err(RenderError::EmptyBuild) => (), Err(err) => { eprintln!("Image could not be rendered:"); |