summaryrefslogtreecommitdiffstats
path: root/cli/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src/main.rs')
-rw-r--r--cli/src/main.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
index a760401..6de8dbd 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -23,6 +23,26 @@ enum Command {
description: String,
},
+ List {
+ target: ListTarget,
+ }
+}
+
+#[derive(Debug)]
+#[derive(StructOpt)]
+enum ListTarget {
+ Categories,
+}
+
+impl std::str::FromStr for ListTarget {
+ type Err = String;
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ match s {
+ "categories" => Ok(ListTarget::Categories),
+ _ => Err(format!("Unknown listable: {:?}", s)),
+ }
+ }
}
#[derive(Debug)]
@@ -36,8 +56,9 @@ struct Mn {
fn main() {
let mut store = model::Store::open(PathBuf::from("store")).unwrap();
- println!("{:?}", store);
- match Mn::from_args().command {
+ let args = Mn::from_args();
+ println!("{:?}", args);
+ match args.command {
Command::Insert {
kind,
account,
@@ -57,5 +78,10 @@ fn main() {
store.push(transaction);
store.write().unwrap();
}
+ Command::List {
+ target: ListTarget::Categories
+ } => {
+ println!("{:?}", store.categories());
+ }
}
}