|
|
|
@ -119,12 +119,14 @@ fn add(id: &String) -> io::Result<()> {
|
|
|
|
|
let passphrase = login()?; |
|
|
|
|
let mut st = Storage::from_db(passphrase)?; |
|
|
|
|
if st.contains(id) { |
|
|
|
|
// TODO: ask to edit existing in outer function which invoked this one
|
|
|
|
|
return Err(io::Error::new( |
|
|
|
|
io::ErrorKind::InvalidInput, |
|
|
|
|
format!("Dublicate item id: {}. Item id's must be unique.", id) |
|
|
|
|
// TODO: ask to edit [Y/n]
|
|
|
|
|
)) |
|
|
|
|
let question = format!("Item [{}] exist. Do you want to edit it instead?", id); |
|
|
|
|
match get_prompt(&question)? { |
|
|
|
|
PROMPT::YES => { |
|
|
|
|
edit(id)?; |
|
|
|
|
return Ok(()); |
|
|
|
|
}, |
|
|
|
|
PROMPT::NO => return Ok(()), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let content = editor::open_to_edit()?; |
|
|
|
|