switch to clap derive instead of builder

This commit is contained in:
2024-07-15 14:54:25 -04:00
parent 55801384eb
commit 02ba19d709
10 changed files with 221 additions and 187 deletions

View File

@ -3,23 +3,24 @@
windows_subsystem = "windows"
)]
use creddy::{
app,
errors::ShowError,
};
use creddy_cli::{Action, Cli};
fn main() {
let global_matches = creddy_cli::parser().get_matches();
let res = match global_matches.subcommand() {
None | Some(("run", _)) => {
let cli = Cli::parse();
let res = match cli.action {
None | Some(Action::Run) => {
app::run().error_popup("Creddy encountered an error");
Ok(())
},
Some(("get", m)) => creddy_cli::get(m, &global_matches),
Some(("exec", m)) => creddy_cli::exec(m, &global_matches),
Some(("shortcut", m)) => creddy_cli::invoke_shortcut(m, &global_matches),
_ => unreachable!(),
Some(Action::Get(args)) => creddy_cli::get(args, cli.global_args),
Some(Action::Exec(args)) => creddy_cli::exec(args, cli.global_args),
Some(Action::Shortcut(args)) => creddy_cli::invoke_shortcut(args, cli.global_args),
};
if let Err(e) = res {