Make sq network dane generate require cert designators or --all.

- Fixes #476.
This commit is contained in:
Justus Winter 2024-12-04 14:39:20 +01:00
parent 7397a8a440
commit 98203e6cd0
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
2 changed files with 13 additions and 2 deletions

View File

@ -8,7 +8,7 @@ use crate::cli::types::FileOrStdout;
use crate::cli::types::cert_designator::{
CertDesignators,
CertUserIDEmailFileArgs,
OptionalValue,
CertOrAll,
CertPrefix,
};
@ -103,7 +103,7 @@ pub struct GenerateCommand {
#[command(flatten)]
pub certs: CertDesignators<CertUserIDEmailFileArgs,
CertPrefix,
OptionalValue>,
CertOrAll>,
#[clap(
long = "all",

View File

@ -233,6 +233,12 @@ pub type FileRequiresOutput = typenum::U4;
pub type OneValueAndFileRequiresOutput
= <OneValue as BitOr<FileRequiresOutput>>::Output;
/// Require either a cert designator, or the `all` parameter.
///
/// Note: the `all` parameter is not part of the cert designators
/// argument, but must be explicitly added.
pub type CertOrAll = typenum::U8;
// Additional documentation.
/// The prefix for the designators.
@ -541,6 +547,7 @@ where
let optional_value = (options & OptionalValue::to_usize()) > 0;
let file_requires_output =
(options & FileRequiresOutput::to_usize()) > 0;
let cert_or_all = (options & CertOrAll::to_usize()) > 0;
let group = format!("cert-designator-{}-{:X}-{:X}",
Prefix::name(),
@ -559,6 +566,10 @@ where
arg_group = arg_group.required(true);
}
if cert_or_all {
arg_group = arg_group.arg("all");
}
let action = if one_value {
clap::ArgAction::Set
} else {