Get the last item when using --get with no ids/tags/meta.
This commit is contained in:
@@ -394,9 +394,7 @@ 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<()> {
|
||||
if ids.is_empty() && tags.is_empty() {
|
||||
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() {
|
||||
if ! ids.is_empty() && ! tags.is_empty() {
|
||||
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 {
|
||||
cmd.error(ErrorKind::InvalidValue, "More than one ID given, you must supply exactly one ID or atleast one tag when using --get").exit();
|
||||
@@ -411,7 +409,7 @@ fn mode_get(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<St
|
||||
let item_maybe = match tags.is_empty() && meta.is_empty() {
|
||||
true => match ids.iter().next() {
|
||||
Some(item_id) => db::get_item(conn, *item_id)?,
|
||||
None => None
|
||||
None => db::get_item_last(conn)?
|
||||
},
|
||||
false => db::get_item_matching(conn, tags, &meta)?
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user