From 457a48f4e696435c51c268f07af0e5a0972e981c Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 17 Apr 2026 01:01:08 +0800 Subject: Add cat command to output bill content --- src/cli.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/cli.rs b/src/cli.rs index a62d41c..44c1f8f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -40,6 +40,7 @@ pub async fn entry() { // Add Dispatchers program.with_dispatchers(( ClearAllBillCommand, + CatCommand, AddBillCommand, EditCommand, ListAllBillCommand, @@ -58,6 +59,7 @@ pub async fn entry() { } dispatcher!("clear", ClearAllBillCommand => ClearAllBillEntry); +dispatcher!("cat", CatCommand => CatEntry); dispatcher!("add", AddBillCommand => AddBillEntry); dispatcher!("edit", EditCommand => EditEntry); dispatcher!("ls", ListAllBillCommand => ListAllBillEntry); @@ -159,6 +161,18 @@ async fn do_clear_cmd(_prev: ClearAllBillEntry) -> NextProcess { Empty::new(()).to_render() } +pack!(ResultCat = String); + +#[chain] +async fn read_cat_cmd(_prev: CatEntry) -> NextProcess { + ResultCat::new(read_bills().table()).to_render() +} + +#[renderer] +fn render_cat_result(prev: ResultCat) { + r_println!("{}", prev.inner.trim()) +} + pack!(StateAddBillItem = BillItem); #[chain] @@ -393,4 +407,9 @@ async fn edit_with_nano(_prev: EditWithNanoEntry) -> NextProcess { EditEntry::new(string_vec!["-e", "nano"]).to_chain() } +#[renderer] +fn fallback_dispatcher_not_found(prev: DispatcherNotFound) { + r_println!("Error: Unknown command \"{}\"", prev.inner.join(" ")); +} + gen_program!(); -- cgit