jt.rs
1 use jt::config::Configuration; 2 use jt::opt::{Opt, SubCommand}; 3 4 use clap::Parser; 5 6 fn main() { 7 if let Err(err) = do_work() { 8 eprintln!("ERROR: {err:?}"); 9 std::process::exit(1); 10 } 11 } 12 13 fn do_work() -> anyhow::Result<()> { 14 env_logger::init_from_env("JT_LOG"); 15 let opt = Opt::parse(); 16 let config = Configuration::read(&opt)?; 17 match opt.cmd { 18 SubCommand::Config(x) => x.run(&config)?, 19 SubCommand::Init(x) => x.run(&config)?, 20 SubCommand::IsJournal(x) => x.run(&config)?, 21 SubCommand::New(x) => x.run(&config)?, 22 SubCommand::NewTopic(x) => x.run(&config)?, 23 SubCommand::List(x) => x.run(&config)?, 24 SubCommand::Edit(x) => x.run(&config)?, 25 SubCommand::Remove(x) => x.run(&config)?, 26 SubCommand::Finish(x) => x.run(&config)?, 27 } 28 Ok(()) 29 }