From 43206da6f40027715582599baa0ad1c91477539e Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Thu, 22 Dec 2022 19:18:56 +0100 Subject: added current list info --- Cargo.lock | 2 +- Cargo.toml | 2 +- data.db | Bin 24576 -> 24576 bytes planmodlist.xopp | Bin 243533 -> 227774 bytes src/commands/list.rs | 12 +++++++----- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7738d3..6fb495c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -647,7 +647,7 @@ dependencies = [ [[package]] name = "modlist" -version = "0.5.2" +version = "0.6.0" dependencies = [ "chrono", "config", diff --git a/Cargo.toml b/Cargo.toml index a881bfc..13280a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "modlist" -version = "0.6.0" +version = "0.6.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/data.db b/data.db index b9aacd5..322caab 100644 Binary files a/data.db and b/data.db differ diff --git a/planmodlist.xopp b/planmodlist.xopp index 30007d4..ef99663 100644 Binary files a/planmodlist.xopp and b/planmodlist.xopp differ diff --git a/src/commands/list.rs b/src/commands/list.rs index 096ce65..bc9e67e 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -17,7 +17,7 @@ pub fn list(config: Cfg, input: Input) -> Result<(), Box> add(config, input.args.ok_or("")?) }, Subcmd::Change => { - change(config, input.args.ok_or("")?) + change(config, input.args) }, Subcmd::Remove => { remove(config, input.args.ok_or("")?) @@ -48,16 +48,18 @@ fn add(config: Cfg, args: Vec) -> Result<(), Box> } } -fn change(config: Cfg, args: Vec) -> Result<(), Box> { +fn change(config: Cfg, args: Option>) -> Result<(), Box> { let lists = lists_get_all_ids(config.clone())?; - match args.len() { + if args.is_none() { println!("Currently selected list: {}", get_current_list(config)?.id); return Ok(()) }; + let argsvec = args.ok_or("BAH")?; + match argsvec.len() { 1 => { - let list = String::from(&args[0]); + let list = String::from(&argsvec[0]); if !lists.contains(&list) { return Err(Box::new(Error::new(ErrorKind::NotFound, "LIST_DOESNT_EXIST"))); }; config_change_current_list(config, list) }, 2.. => Err(Box::new(Error::new(ErrorKind::InvalidInput, "TOO_MANY_ARGUMENTS"))), - _ => panic!("list arguments should never be zero or lower"), + _ => panic!("list arguments should never lower than zero"), } } -- cgit v1.2.3