Refactor files in /cli/cert to new example framework

- no content changes
- see: #451
This commit is contained in:
franzi 2024-12-05 15:23:53 +01:00 committed by Justus Winter
parent 898ccc753f
commit 03578878fe
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
3 changed files with 39 additions and 59 deletions

View File

@ -5,17 +5,14 @@ use clap::Parser;
use crate::cli::examples;
use examples::Action;
use examples::Actions;
use examples::Example;
const EXAMPLES: Actions = Actions {
actions: &[
Action::Example(Example {
comment: "Import a certificate.",
command: &[
Action::example().comment(
"Import a certificate."
).command(&[
"sq", "cert", "import", "juliet.pgp",
],
hide: &[],
}),
]).build(),
]
};

View File

@ -66,41 +66,31 @@ pub struct Command {
const EXAMPLES: Actions = Actions {
actions: &[
Action::Setup(Setup {
command: &[
Action::setup().command(&[
"sq", "keyring", "merge",
"--output=certs.pgp",
"bob.pgp", "romeo.pgp",
],
}),
]).build(),
Action::Setup(Setup {
command: &[
Action::setup().command(&[
"sq", "key", "import", "alice-secret.pgp",
],
}),
]).build(),
Action::Example(Example {
comment: "\
Gather statistics on the certificates in a keyring.",
command: &[
Action::example().comment(
" Gather statistics on the certificates in a keyring."
).command (&[
"sq", "cert", "lint",
"--cert-file", "certs.pgp",
],
hide: &[],
}),
]).build(),
Action::Example(Example {
comment: "\
Fix a key with known problems.",
command: &[
Action::example().comment(
"Fix a key with known problems."
).command (&[
"sq", "key", "export",
"--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
"|", "sq", "cert", "lint", "--fix", "--cert-file=-",
"|", "sq", "cert", "import"
],
hide: &[],
}),
]).build(),
],
};
test_examples!(sq_cert_lint, EXAMPLES);

View File

@ -4,8 +4,6 @@ use clap::Parser;
use crate::cli::examples::Action;
use crate::cli::examples::Actions;
use crate::cli::examples::Example;
use crate::cli::examples::Setup;
use crate::cli::pki::CertificationNetworkArg;
use crate::cli::pki::GossipArg;
use crate::cli::pki::RequiredTrustAmountArg;
@ -15,22 +13,18 @@ use crate::cli::types::userid_designator;
const EXAMPLES: Actions = Actions {
actions: &[
Action::Setup(Setup {
command: &[
Action::setup().command(&[
"sq", "pki", "link", "add",
"--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0",
"--all",
],
}),
Action::Example(Example {
comment: "\
List all bindings for user IDs containing an email address from \
example.org, and that can be authenticated.",
command: &[
]).build(),
Action::example().comment(
"List all bindings for user IDs containing an email address from \
example.org, and that can be authenticated."
).command (&[
"sq", "cert", "list", "@example.org",
],
hide: &[],
})
]).build(),
]
};
test_examples!(sq_cert_list, EXAMPLES);
@ -83,4 +77,3 @@ pub struct Command {
#[command(flatten)]
pub trust_amount: RequiredTrustAmountArg,
}