From 03578878fea7beab26d1ecc16ef348bc5f94f008 Mon Sep 17 00:00:00 2001 From: franzi Date: Thu, 5 Dec 2024 15:23:53 +0100 Subject: [PATCH] Refactor files in /cli/cert to new example framework - no content changes - see: #451 --- src/cli/cert/import.rs | 13 ++++------ src/cli/cert/lint.rs | 54 +++++++++++++++++------------------------- src/cli/cert/list.rs | 31 ++++++++++-------------- 3 files changed, 39 insertions(+), 59 deletions(-) diff --git a/src/cli/cert/import.rs b/src/cli/cert/import.rs index a030c296..e90f64c7 100644 --- a/src/cli/cert/import.rs +++ b/src/cli/cert/import.rs @@ -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: &[ - "sq", "cert", "import", "juliet.pgp", - ], - hide: &[], - }), + Action::example().comment( + "Import a certificate." + ).command(&[ + "sq", "cert", "import", "juliet.pgp", + ]).build(), ] }; diff --git a/src/cli/cert/lint.rs b/src/cli/cert/lint.rs index 8c994e46..e80f248d 100644 --- a/src/cli/cert/lint.rs +++ b/src/cli/cert/lint.rs @@ -66,41 +66,31 @@ pub struct Command { const EXAMPLES: Actions = Actions { actions: &[ - Action::Setup(Setup { - command: &[ - "sq", "keyring", "merge", - "--output=certs.pgp", - "bob.pgp", "romeo.pgp", - ], - }), + Action::setup().command(&[ + "sq", "keyring", "merge", + "--output=certs.pgp", + "bob.pgp", "romeo.pgp", + ]).build(), - Action::Setup(Setup { - command: &[ - "sq", "key", "import", "alice-secret.pgp", - ], - }), + Action::setup().command(&[ + "sq", "key", "import", "alice-secret.pgp", + ]).build(), - Action::Example(Example { - comment: "\ -Gather statistics on the certificates in a keyring.", - command: &[ - "sq", "cert", "lint", - "--cert-file", "certs.pgp", - ], - hide: &[], - }), + Action::example().comment( + " Gather statistics on the certificates in a keyring." + ).command (&[ + "sq", "cert", "lint", + "--cert-file", "certs.pgp", + ]).build(), - Action::Example(Example { - comment: "\ -Fix a key with known problems.", - command: &[ - "sq", "key", "export", - "--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0", - "|", "sq", "cert", "lint", "--fix", "--cert-file=-", - "|", "sq", "cert", "import" - ], - hide: &[], - }), + Action::example().comment( + "Fix a key with known problems." + ).command (&[ + "sq", "key", "export", + "--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0", + "|", "sq", "cert", "lint", "--fix", "--cert-file=-", + "|", "sq", "cert", "import" + ]).build(), ], }; test_examples!(sq_cert_lint, EXAMPLES); diff --git a/src/cli/cert/list.rs b/src/cli/cert/list.rs index 40e49b5d..75d0c9ce 100644 --- a/src/cli/cert/list.rs +++ b/src/cli/cert/list.rs @@ -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: &[ - "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: &[ - "sq", "cert", "list", "@example.org", - ], - hide: &[], - }) + Action::setup().command(&[ + "sq", "pki", "link", "add", + "--cert", "EB28F26E2739A4870ECC47726F0073F60FD0CBF0", + "--all", + ]).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", + ]).build(), ] }; test_examples!(sq_cert_list, EXAMPLES); @@ -83,4 +77,3 @@ pub struct Command { #[command(flatten)] pub trust_amount: RequiredTrustAmountArg, } -