aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli.rs19
1 files changed, 19 insertions, 0 deletions
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!();