use pico_args::Arguments; mod command; mod env; mod error; mod flag; mod help; mod state; mod util; use help::{ help, version }; use state::State; static VERSION: &str = env!("CARGO_PKG_VERSION"); fn main() { // collect args let mut args = Arguments::from_env(); // consume flags if args.contains(flag::HELP) { help(&mut args); return; } if args.contains(flag::VERSION) { version(); return; } let mut state = State::new(&mut args); let target = state.target(); // invoke subcommand function match target.as_deref() { Some("help") => help(&mut args), None => command::share::context_action(&state), Some("a" | "attach") => command::share::attach(&mut state), Some("d" | "detach") => command::share::detach(&mut state), Some("h" | "has") => command::share::has(&mut state), Some("l" | "ls" | "list") => command::share::list(&state), Some("n" | "new") => command::share::new(&mut state), Some("p" | "path") => command::session::path(&mut state), Some("s" | "switch") => command::session::switch(&mut state), Some("w" | "which" | "title") => command::session::which(state), _ => error::no_subcommand(target.unwrap()) } }