|
|
@ -27,20 +27,24 @@ enum Commands { |
|
|
|
/// Lists all ids stored in db
|
|
|
|
/// Lists all ids stored in db
|
|
|
|
List, |
|
|
|
List, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Show content of item
|
|
|
|
|
|
|
|
Show { |
|
|
|
|
|
|
|
#[arg(value_name="item_id")] |
|
|
|
|
|
|
|
id: String |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/// Adds new item with unique id to the db
|
|
|
|
/// Adds new item with unique id to the db
|
|
|
|
Add { |
|
|
|
Add { |
|
|
|
#[arg(value_name="item_id")] |
|
|
|
#[arg(value_name="item_id")] |
|
|
|
id: String |
|
|
|
id: String |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/// Show content of item
|
|
|
|
/// Edit item content
|
|
|
|
Show { |
|
|
|
Edit { |
|
|
|
#[arg(value_name="item_id")] |
|
|
|
#[arg(value_name="item_id")] |
|
|
|
id: String |
|
|
|
id: String |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: edit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
enum PROMPT { |
|
|
|
enum PROMPT { |
|
|
@ -130,6 +134,11 @@ fn add(id: &String) -> io::Result<()> { |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn edit(id: &String) -> io::Result<()> { |
|
|
|
|
|
|
|
// TODO: implement
|
|
|
|
|
|
|
|
Ok(()) |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn show(id: &String) -> io::Result<()> { |
|
|
|
fn show(id: &String) -> io::Result<()> { |
|
|
|
let passphrase = login()?;
|
|
|
|
let passphrase = login()?;
|
|
|
|
let mut st = Storage::from_db(passphrase)?; |
|
|
|
let mut st = Storage::from_db(passphrase)?; |
|
|
@ -151,14 +160,17 @@ fn run_command() -> io::Result<()> { |
|
|
|
Some(Commands::Init) => { |
|
|
|
Some(Commands::Init) => { |
|
|
|
init()?; |
|
|
|
init()?; |
|
|
|
} |
|
|
|
} |
|
|
|
Some(Commands::Add{ id }) => { |
|
|
|
Some(Commands::List) => { |
|
|
|
add(id)?; |
|
|
|
list()?; |
|
|
|
} |
|
|
|
} |
|
|
|
Some(Commands::Show { id }) => { |
|
|
|
Some(Commands::Show { id }) => { |
|
|
|
show(id)?; |
|
|
|
show(id)?; |
|
|
|
} |
|
|
|
} |
|
|
|
Some(Commands::List) => { |
|
|
|
Some(Commands::Add { id }) => { |
|
|
|
list()?; |
|
|
|
add(id)?; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Some(Commands::Edit { id }) => { |
|
|
|
|
|
|
|
edit(id)? |
|
|
|
} |
|
|
|
} |
|
|
|
None => { |
|
|
|
None => { |
|
|
|
if !Storage::is_inited() { |
|
|
|
if !Storage::is_inited() { |
|
|
|