diff options
author | Justus Winter <justus@pep-project.org> | 2018-01-09 17:00:42 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-01-10 14:35:44 +0100 |
commit | 5bb31b8b2f042b44cb9af5f0a63c1ad978a53ea0 (patch) | |
tree | 4bbec189bf0755769bba300390e7ce10b348d74f /tool | |
parent | ee4107c5457f25b0b3b0e0022f5226d9d13b6545 (diff) |
store: Implement store and binding deletion.
- Also add commands in the tool.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/src/main.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tool/src/main.rs b/tool/src/main.rs index 0d06266c..dd791252 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -147,6 +147,14 @@ fn real_main() -> Result<()> { .long("armor") .short("A") .help("Write armored data to file"))) + .subcommand(SubCommand::with_name("delete") + .about("Deletes bindings or stores") + .arg(Arg::with_name("the-store") + .long("the-store") + .help("Delete the whole store")) + .arg(Arg::with_name("label") + .value_name("LABEL") + .help("Delete binding with this label"))) .subcommand(SubCommand::with_name("stats") .about("Get stats for the given label") .arg(Arg::with_name("label").value_name("LABEL") @@ -298,6 +306,20 @@ fn real_main() -> Result<()> { tpk.serialize(&mut output) .expect("Failed to write the key"); }, + ("delete", Some(m)) => { + if m.is_present("label") == m.is_present("the-store") { + eprintln!("Please specify either a label or --the-store."); + exit(1); + } + + if m.is_present("the-store") { + store.delete().expect("Failed to delete the store"); + } else { + let binding = store.lookup(m.value_of("label").unwrap()) + .expect("Failed to get key"); + binding.delete().expect("Failed to delete the binding"); + } + }, ("stats", Some(m)) => { let binding = store.lookup(m.value_of("label").unwrap()) .expect("Failed to get key"); |