diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-07-29 09:56:13 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-07-29 10:19:31 +0200 |
| commit | ccda716764ae84dee9f18f66e383b66c9e30b3b9 (patch) | |
| tree | 40d5b679d76308233f599c57a4751b5ca14d1390 /cli/src/main.rs | |
| parent | 5216a6a67d1bde60f4c872b8d8d966efe02dd4e4 (diff) | |
| download | money-ccda716764ae84dee9f18f66e383b66c9e30b3b9.tar.gz | |
list categories
Diffstat (limited to 'cli/src/main.rs')
| -rw-r--r-- | cli/src/main.rs | 30 |
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()); + } } } |
