| 1 |
use clap::Args; |
| 2 |
|
| 3 |
use crate::cli::examples; |
| 4 |
use examples::Action; |
| 5 |
use examples::Actions; |
| 6 |
|
| 7 |
use crate::cli::types::CertDesignators; |
| 8 |
use crate::cli::types::ClapData; |
| 9 |
use crate::cli::types::FileOrStdout; |
| 10 |
use crate::cli::types::KeyDesignators; |
| 11 |
use crate::cli::types::cert_designator; |
| 12 |
use crate::cli::types::key_designator; |
| 13 |
|
| 14 |
pub struct CertAdditionalDocs {} |
| 15 |
|
| 16 |
impl cert_designator::AdditionalDocs for CertAdditionalDocs { |
| 17 |
fn help(arg: &'static str, help: &'static str) -> clap::builder::StyledStr { |
| 18 |
match arg { |
| 19 |
"file" => |
| 20 |
"Delete the secret key material from the key read from PATH" |
| 21 |
.into(), |
| 22 |
_ => { |
| 23 |
debug_assert!(help.starts_with("Use certificates")); |
| 24 |
help.replace("Use certificates", |
| 25 |
"Delete secret key material from the key") |
| 26 |
}, |
| 27 |
}.into() |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
pub struct KeyAdditionalDocs {} |
| 32 |
|
| 33 |
impl key_designator::AdditionalDocs for KeyAdditionalDocs { |
| 34 |
fn help(_arg: &'static str, _help: &'static str) |
| 35 |
-> clap::builder::StyledStr |
| 36 |
{ |
| 37 |
"Delete the specified key's secret key material".into() |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
#[derive(Debug, Args)] |
| 42 |
#[clap( |
| 43 |
name = "delete", |
| 44 |
about = "Delete a certificate's secret key material", |
| 45 |
long_about = "\ |
| 46 |
Delete a certificate's secret key material |
| 47 |
|
| 48 |
Unlike `sq key delete`, which deletes all the secret key material, this \ |
| 49 |
command only deletes the specified secret key material. |
| 50 |
|
| 51 |
If the secret key material is managed by multiple devices, it is \ |
| 52 |
deleted from all of them. |
| 53 |
|
| 54 |
Although the secret key material is deleted, the public keys are \ |
| 55 |
retained. If you don't want the keys to be used anymore you should \ |
| 56 |
revoke the keys using `sq key subkey revoke`. |
| 57 |
", |
| 58 |
after_help = EXAMPLES, |
| 59 |
)] |
| 60 |
pub struct Command { |
| 61 |
#[command(flatten)] |
| 62 |
pub cert: CertDesignators< |
| 63 |
cert_designator::CertUserIDEmailFileArgs, |
| 64 |
cert_designator::CertPrefix, |
| 65 |
cert_designator::OneValueAndFileRequiresOutput, |
| 66 |
CertAdditionalDocs>, |
| 67 |
|
| 68 |
#[command(flatten)] |
| 69 |
pub keys: KeyDesignators< |
| 70 |
key_designator::DefaultOptions, |
| 71 |
KeyAdditionalDocs>, |
| 72 |
|
| 73 |
#[clap( |
| 74 |
long, |
| 75 |
value_name = FileOrStdout::VALUE_NAME, |
| 76 |
conflicts_with = "cert", |
| 77 |
help = "Write the stripped certificate to the specified file", |
| 78 |
long_help = "\ |
| 79 |
Write the stripped certificate to the specified file |
| 80 |
|
| 81 |
This option only makes sense when deleting the secret key material from a \ |
| 82 |
file. When deleting secret key material managed by the key store using \ |
| 83 |
`--cert`, you can get the stripped certificate using `sq key export`.", |
| 84 |
)] |
| 85 |
pub output: Option<FileOrStdout>, |
| 86 |
} |
| 87 |
|
| 88 |
const EXAMPLES: Actions = Actions { |
| 89 |
actions: &[ |
| 90 |
Action::setup().command(&[ |
| 91 |
"sq", "key", "import", "alice-secret.pgp" |
| 92 |
]).build(), |
| 93 |
|
| 94 |
Action::example().comment("\ |
| 95 |
Delete Alice's signing subkey." |
| 96 |
).command(&[ |
| 97 |
"sq", "key", "subkey", "delete", |
| 98 |
"--cert=EB28F26E2739A4870ECC47726F0073F60FD0CBF0", |
| 99 |
"--key=42020B87D51877E5AF8D272124F3955B0B8DECC8", |
| 100 |
]).build(), |
| 101 |
] |
| 102 |
}; |
| 103 |
test_examples!(sq_key_subkey_delete, EXAMPLES); |