diff --git a/Cargo.lock b/Cargo.lock index e44b32e..7109c7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "afrim" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1435b8358111974ffa640bf6fb9868ad79d0492c1679357e68d0afa493cee2af" +checksum = "f125fedbda3e1135208daba39349b4fa0c01f2a20eca16ea739498cc6e14c856" dependencies = [ "afrim-config", "afrim-preprocessor", @@ -25,7 +25,7 @@ dependencies = [ "indexmap", "rhai", "serde", - "toml 0.8.8", + "toml", ] [[package]] @@ -46,9 +46,9 @@ dependencies = [ [[package]] name = "afrim-translator" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "268898eb5e7ce66a6e1e0c440232ad264603ba4505ecc92bb09f878f60dea589" +checksum = "13da25093a97c18a84988182fdf92a5a38d41d29b52368c17687587be2285b19" dependencies = [ "indexmap", "rhai", @@ -60,9 +60,10 @@ name = "afrim-wish" version = "0.3.1" dependencies = [ "afrim", + "clap", "rstk", "serde", - "toml 0.7.8", + "toml", ] [[package]] @@ -162,9 +163,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", "clap_derive", @@ -172,9 +173,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.7" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", @@ -647,18 +648,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "toml" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit 0.19.15", -] - [[package]] name = "toml" version = "0.8.8" @@ -668,7 +657,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.21.0", + "toml_edit", ] [[package]] @@ -680,19 +669,6 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "toml_edit" version = "0.21.0" diff --git a/Cargo.toml b/Cargo.toml index 082ff3f..7083179 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ rhai = ["afrim/rhai"] [dependencies] afrim = { version = "0.5.2", default-features = false } +clap = "4.4.8" rstk = "0.1.0" serde = { version = "1.0.192", features = ["serde_derive"] } toml = "0.8.8" diff --git a/src/main.rs b/src/main.rs index 59c3d4e..fcbe6a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,20 +2,30 @@ use afrim::{run, Config as ClafricaConfig}; use afrim_wish::{Config as WishConfig, Wish}; -use std::{env, path::Path, process}; +use clap::Parser; +use std::process; + +/// Afrim CLI. +#[derive(Parser)] +#[command(author, version, about, long_about = None)] +struct Args { + /// Path to the configuration file. + config_file: std::path::PathBuf, + + /// Only verify if the configuration file is valid. + #[arg(long, action)] + check: bool, +} fn main() { - let filename = env::args().nth(1).unwrap_or_else(|| { - eprintln!("Configuration file required"); - process::exit(1); - }); + let args = Args::parse(); - let clafrica_conf = ClafricaConfig::from_file(Path::new(&filename)).unwrap_or_else(|err| { + let clafrica_conf = ClafricaConfig::from_file(&args.config_file).unwrap_or_else(|err| { eprintln!("Problem parsing config file: {err}"); process::exit(1); }); - let wish_conf = WishConfig::from_file(Path::new(&filename)).unwrap_or_else(|err| { + let wish_conf = WishConfig::from_file(&args.config_file).unwrap_or_else(|err| { eprintln!("Problem parsing config file: {err}"); process::exit(1); });