Make subcommand optional
This commit is contained in:
parent
64742a0e21
commit
bb87581ea5
@ -12,7 +12,7 @@ pub struct EnvOpt {
|
||||
)]
|
||||
pub config: PathBuf,
|
||||
#[argh(subcommand)]
|
||||
pub subcommand: Subcommand,
|
||||
pub subcommand: Option<Subcommand>,
|
||||
}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
|
@ -6,7 +6,7 @@ use thingy_lib::chrono::NaiveDateTime;
|
||||
use thingy_lib::{try_get_datetime, Config, MessagedError};
|
||||
|
||||
pub fn from_env(env: EnvOpt) -> Result<(), GenericError> {
|
||||
match env.subcommand {
|
||||
match env.subcommand.unwrap() {
|
||||
Subcommand::Between(opt) => {
|
||||
let config = Config::from_path(&env.config)?;
|
||||
let mut api = API::new(config.clone());
|
||||
|
@ -12,8 +12,12 @@ use thingy_lib::Config;
|
||||
|
||||
fn main() {
|
||||
let env: EnvOpt = argh::from_env();
|
||||
if env.subcommand.is_some() {
|
||||
if let Err(e) = cmd::from_env(env) {
|
||||
eprintln!("Critical Error: {}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
} else {
|
||||
println!("Open nwg UI instead");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user