diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-04-19 01:27:36 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-04-19 01:27:36 +0800 |
| commit | 2390e7cdf2db261f8c2f035858c86a1aab6c40de (patch) | |
| tree | 3e7812eb14faf4eaa1d4c4bf83b729aadaa2a3b2 /src/cli.rs | |
| parent | 5f4c99bd22deb235aa912078bf74726ec38c0b55 (diff) | |
Remove tokio dependency and convert to synchronous code
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -18,7 +18,7 @@ use crate::{ string_vec, }; -pub async fn entry() { +pub fn entry() { let mut program = ThisProgram::new(); if program.pick_global_flag(["-v", "--version"]) { @@ -55,7 +55,7 @@ pub async fn entry() { )); // Execute - program.exec().await; + program.exec(); } dispatcher!("clear", ClearAllBillCommand => ClearAllBillEntry); @@ -156,7 +156,7 @@ fn comp_edit(ctx: &ShellContext) -> Suggest { } #[chain] -async fn do_clear_cmd(_prev: ClearAllBillEntry) -> NextProcess { +fn do_clear_cmd(_prev: ClearAllBillEntry) -> NextProcess { op_bills(|b| b.clear_items()); Empty::new(()).to_render() } @@ -164,7 +164,7 @@ async fn do_clear_cmd(_prev: ClearAllBillEntry) -> NextProcess { pack!(ResultCat = String); #[chain] -async fn read_cat_cmd(_prev: CatEntry) -> NextProcess { +fn read_cat_cmd(_prev: CatEntry) -> NextProcess { ResultCat::new(read_bills().table()).to_render() } @@ -176,7 +176,7 @@ fn render_cat_result(prev: ResultCat) { pack!(StateAddBillItem = BillItem); #[chain] -async fn parse_add_cmd(prev: AddBillEntry) -> NextProcess { +fn parse_add_cmd(prev: AddBillEntry) -> NextProcess { let picked = Picker::new(prev.inner) .pick_or_route::<f64>(["--paid", "-p"], PaidRequired::new(()).to_render()) .pick_or_route::<Vec<String>>(["--for", "-f"], ForMembersRequired::new(()).to_render()) @@ -202,7 +202,7 @@ async fn parse_add_cmd(prev: AddBillEntry) -> NextProcess { } #[chain] -async fn handle_add_bill_item(prev: StateAddBillItem) -> NextProcess { +fn handle_add_bill_item(prev: StateAddBillItem) -> NextProcess { op_bills(|b| { b.add_item(prev.inner); }); @@ -220,7 +220,7 @@ pack!(ErrorDuplicateSplitMembers = ()); pack!(ErrorNegativePaidAmount = ()); #[chain] -async fn parse_ls_cmd(prev: ListAllBillEntry) -> NextProcess { +fn parse_ls_cmd(prev: ListAllBillEntry) -> NextProcess { let optimize = Picker::<()>::new(prev.inner) .pick::<bool>(["-O", "--optimize"]) .unpack_directly() @@ -229,7 +229,7 @@ async fn parse_ls_cmd(prev: ListAllBillEntry) -> NextProcess { } #[chain] -async fn handle_list_bills(prev: StateListBills) -> NextProcess { +fn handle_list_bills(prev: StateListBills) -> NextProcess { if prev.optimize { let bills = read_bills(); match calculate_from(bills) { @@ -263,7 +263,7 @@ pack!(StateEditBills = String); // Editor name pack!(ErrorEditorNotFound = String); #[chain] -async fn parse_edit_cmd(prev: EditEntry) -> NextProcess { +fn parse_edit_cmd(prev: EditEntry) -> NextProcess { let editor = Picker::<()>::new(prev.inner) .pick_or::<String>(["--editor", "-e"], get_default_editor()) .unpack_directly() @@ -273,7 +273,7 @@ async fn parse_edit_cmd(prev: EditEntry) -> NextProcess { } #[chain] -async fn exec_edit_cmd(prev: StateEditBills) -> NextProcess { +fn exec_edit_cmd(prev: StateEditBills) -> NextProcess { let text = match input_with_editor_cutsom( read_bills().table(), state_edit_file_path(), @@ -376,27 +376,27 @@ dispatcher!("helix", EditWithHelixCommand => EditWithHelixEntry); dispatcher!("nano", EditWithNanoCommand => EditWithNanoEntry); #[chain] -async fn edit_with_vi(_prev: EditWithViEntry) -> NextProcess { +fn edit_with_vi(_prev: EditWithViEntry) -> NextProcess { EditEntry::new(string_vec!["-e", "vi"]).to_chain() } #[chain] -async fn edit_with_vim(_prev: EditWithVimEntry) -> NextProcess { +fn edit_with_vim(_prev: EditWithVimEntry) -> NextProcess { EditEntry::new(string_vec!["-e", "vim"]).to_chain() } #[chain] -async fn edit_with_nvim(_prev: EditWithNvimEntry) -> NextProcess { +fn edit_with_nvim(_prev: EditWithNvimEntry) -> NextProcess { EditEntry::new(string_vec!["-e", "nvim"]).to_chain() } #[chain] -async fn edit_with_helix(_prev: EditWithHelixEntry) -> NextProcess { +fn edit_with_helix(_prev: EditWithHelixEntry) -> NextProcess { EditEntry::new(string_vec!["-e", "helix"]).to_chain() } #[chain] -async fn edit_with_nano(_prev: EditWithNanoEntry) -> NextProcess { +fn edit_with_nano(_prev: EditWithNanoEntry) -> NextProcess { EditEntry::new(string_vec!["-e", "nano"]).to_chain() } |
