Merge branch 'nora/mandatory_generate_output' into 'main'
opgpcard: Prevent losing the generated cert. Closes #49 See merge request openpgp-card/openpgp-card!23
This commit is contained in:
commit
2fb4f3961a
2 changed files with 6 additions and 8 deletions
|
@ -86,9 +86,9 @@ pub struct AdminGenerateCommand {
|
|||
#[clap(name = "User PIN file", short = 'p', long = "user-pin")]
|
||||
user_pin: Option<PathBuf>,
|
||||
|
||||
/// Output file (stdout if unset)
|
||||
/// Output file
|
||||
#[clap(name = "output", long = "output", short = 'o')]
|
||||
output_file: Option<PathBuf>,
|
||||
output_file: PathBuf,
|
||||
|
||||
#[clap(long = "no-decrypt", action = clap::ArgAction::SetFalse)]
|
||||
decrypt: bool,
|
||||
|
@ -484,8 +484,8 @@ fn generate_command(
|
|||
let armored = String::from_utf8(cert.armored().to_vec()?)?;
|
||||
output.public_key(armored);
|
||||
|
||||
// Write armored certificate to the output file (or stdout)
|
||||
let mut handle = util::open_or_stdout(cmd.output_file.as_deref())?;
|
||||
// Write armored certificate to the output file
|
||||
let mut handle = util::open_or_stdout(Some(&cmd.output_file))?;
|
||||
handle.write_all(output.print(output_format, output_version)?.as_bytes())?;
|
||||
let _ = handle.write(b"\n")?;
|
||||
|
||||
|
|
|
@ -27,10 +27,8 @@ impl AdminGenerate {
|
|||
}
|
||||
|
||||
fn text(&self) -> Result<String, OpgpCardError> {
|
||||
Ok(format!(
|
||||
"OpenPGP card {}\n\n{}\n",
|
||||
self.ident, self.public_key,
|
||||
))
|
||||
// Do not print ident, as the file with the public_key must not contain anything else
|
||||
Ok(self.public_key.to_string())
|
||||
}
|
||||
|
||||
fn v1(&self) -> Result<AdminGenerateV0, OpgpCardError> {
|
||||
|
|
Loading…
Reference in a new issue