Make tag/id error messages a bit clear

This commit is contained in:
Andrew Phillips
2023-09-01 15:39:03 +00:00
parent 5e539ac2a7
commit 6222748901

View File

@@ -397,11 +397,11 @@ fn mode_save(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<S
fn mode_get(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<String>, conn: &mut Connection, data_path: PathBuf) -> Result<()> { fn mode_get(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<String>, conn: &mut Connection, data_path: PathBuf) -> Result<()> {
if ids.is_empty() && tags.is_empty() { if ids.is_empty() && tags.is_empty() {
cmd.error(ErrorKind::InvalidValue, "No ID or tags given, you must supply one ID or atleast one tag when using --get").exit(); cmd.error(ErrorKind::InvalidValue, "No ID or tags given, you must supply exactly one ID or atleast one tag when using --get").exit();
} else if ! ids.is_empty() && ! tags.is_empty() { } else if ! ids.is_empty() && ! tags.is_empty() {
cmd.error(ErrorKind::InvalidValue, "Both ID and tags given, you must supply one ID or atleast one tag when using --get").exit(); cmd.error(ErrorKind::InvalidValue, "Both ID and tags given, you must supply exactly one ID or atleast one tag when using --get").exit();
} else if ids.len() > 1 { } else if ids.len() > 1 {
cmd.error(ErrorKind::InvalidValue, "More than one ID given, you must supply one ID or atleast one tag when using --get").exit(); cmd.error(ErrorKind::InvalidValue, "More than one ID given, you must supply exactly one ID or atleast one tag when using --get").exit();
} }
let mut meta: HashMap<String, String> = HashMap::new(); let mut meta: HashMap<String, String> = HashMap::new();
@@ -547,6 +547,8 @@ fn mode_list(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &Vec<Strin
fn mode_update(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<String>, conn: &mut Connection) -> Result<()> { fn mode_update(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<String>, conn: &mut Connection) -> Result<()> {
if ids.is_empty() { if ids.is_empty() {
cmd.error(ErrorKind::InvalidValue, "No ID given, you must supply one ID when using --update").exit(); cmd.error(ErrorKind::InvalidValue, "No ID given, you must supply one ID when using --update").exit();
} else if ids.len() > 1 {
cmd.error(ErrorKind::InvalidValue, "More than one ID given, you must supply exactly one ID or atleast one tag when using --update").exit();
} }
let item_id = ids.iter().next().expect("Unable to determine item id"); let item_id = ids.iter().next().expect("Unable to determine item id");