diff options
| -rw-r--r-- | help.txt | 1 | ||||
| -rw-r--r-- | src/cli.rs | 19 |
2 files changed, 20 insertions, 0 deletions
@@ -6,6 +6,7 @@ SYNOPSIS COMMANDS add Add a new bill item + cat Output the content of bills clear Clear all bill items edit Edit bills using a text editor ls List all bills or show optimized split result @@ -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!(); |
