-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the check action, to ask the clafrica to only verify the configuration file.
- Loading branch information
1 parent
79a741c
commit d28da86
Showing
3 changed files
with
146 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
use clafrica::{api, prelude::Config, run}; | ||
use std::{env, path::Path, process}; | ||
use clap::Parser; | ||
use std::process; | ||
|
||
/// Clafrica 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 args = Args::parse(); | ||
let frontend = api::Console::default(); | ||
|
||
let filename = env::args().nth(1).unwrap_or_else(|| { | ||
eprintln!("Configuration file required"); | ||
process::exit(1); | ||
}); | ||
|
||
let conf = Config::from_file(Path::new(&filename)).unwrap_or_else(|err| { | ||
let conf = Config::from_file(&args.config_file).unwrap_or_else(|err| { | ||
eprintln!("Problem parsing config file: {err}"); | ||
process::exit(1); | ||
}); | ||
|
||
if let Err(e) = run(conf, frontend) { | ||
eprintln!("Application error: {e}"); | ||
process::exit(1); | ||
if !args.check { | ||
run(conf, frontend).unwrap_or_else(|e| { | ||
eprintln!("Application error: {e}"); | ||
process::exit(1); | ||
}); | ||
} | ||
} |