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