|
|
@ -128,8 +128,9 @@ fn add(id: &String) -> io::Result<()> { |
|
|
|
PROMPT::NO => return Ok(()), |
|
|
|
PROMPT::NO => return Ok(()), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let content = editor::open_to_edit()?; |
|
|
|
// set empty string because there is no content yet
|
|
|
|
|
|
|
|
let content = editor::open_to_edit(&String::from(""))?; |
|
|
|
st.add(Item::from(id.clone(), content)); |
|
|
|
st.add(Item::from(id.clone(), content)); |
|
|
|
st.dump()?; |
|
|
|
st.dump()?; |
|
|
|
|
|
|
|
|
|
|
@ -138,6 +139,21 @@ fn add(id: &String) -> io::Result<()> { |
|
|
|
|
|
|
|
|
|
|
|
fn edit(id: &String) -> io::Result<()> { |
|
|
|
fn edit(id: &String) -> io::Result<()> { |
|
|
|
// TODO: implement
|
|
|
|
// TODO: implement
|
|
|
|
|
|
|
|
let passphrase = login()?; |
|
|
|
|
|
|
|
let mut st = Storage::from_db(passphrase)?; |
|
|
|
|
|
|
|
if !st.contains(id) { |
|
|
|
|
|
|
|
return Err(io::Error::new( |
|
|
|
|
|
|
|
io::ErrorKind::InvalidInput, |
|
|
|
|
|
|
|
format!("Can`t find id: {}", id) |
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut item = (*st.get(id)).clone(); |
|
|
|
|
|
|
|
let new_content = editor::open_to_edit(&item.content)?; |
|
|
|
|
|
|
|
item.content = new_content; |
|
|
|
|
|
|
|
st.update(item); |
|
|
|
|
|
|
|
st.dump()?; |
|
|
|
|
|
|
|
|
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|