use std::{mem, process};
use guartcl::guardian_interp;
use jimtcl::{JimError, JimResult, cli::Jimsh};
use clap::{CommandFactory, FromArgMatches};
static GUARTCL_VERSION: &str = env!("CARGO_PKG_VERSION");
fn main() -> JimResult<()> {
let interp = guardian_interp()?;
let cli = Jimsh::command()
.about("Enhanced Jim Tcl shell, with Rust-based superpowers")
.version(GUARTCL_VERSION)
.long_version(format!(
"{} (Jim version {})",
GUARTCL_VERSION,
interp.jim_version()?
))
.name("guartcl");
let cli = Jimsh::from_arg_matches(&cli.get_matches())
.map_err(|e| JimError::from(format!("CLI error: {}", e)))?;
let rc = cli.run(&interp)?;
mem::drop(interp);
process::exit(rc);
}