Skip to content

Commit

Permalink
improve the cli
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonbrad committed Nov 11, 2023
1 parent b369117 commit 64a82dc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 43 deletions.
48 changes: 12 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
24 changes: 17 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 64a82dc

Please sign in to comment.