From cd06a3b302d7ca985cf5a96a264fab7675625565 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 24 Jan 2026 04:23:23 +0100 Subject: [PATCH] refactor: move flags related to revoke to flags.go --- cmd/cmd_revoke.go | 31 ------------------------------- cmd/flags.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/cmd/cmd_revoke.go b/cmd/cmd_revoke.go index 4926a4458..522dee0d8 100644 --- a/cmd/cmd_revoke.go +++ b/cmd/cmd_revoke.go @@ -4,18 +4,11 @@ import ( "context" "log/slog" - "github.com/go-acme/lego/v5/acme" "github.com/go-acme/lego/v5/cmd/internal/storage" "github.com/go-acme/lego/v5/log" "github.com/urfave/cli/v3" ) -// Flag names. -const ( - flgKeep = "keep" - flgReason = "reason" -) - func createRevoke() *cli.Command { return &cli.Command{ Name: "revoke", @@ -25,30 +18,6 @@ func createRevoke() *cli.Command { } } -func createRevokeFlags() []cli.Flag { - flags := CreateBaseFlags() - - flags = append(flags, - &cli.BoolFlag{ - Name: flgKeep, - Aliases: []string{"k"}, - Usage: "Keep the certificates after the revocation instead of archiving them.", - }, - &cli.UintFlag{ - Name: flgReason, - Usage: "Identifies the reason for the certificate revocation." + - " See https://www.rfc-editor.org/rfc/rfc5280.html#section-5.3.1." + - " Valid values are:" + - " 0 (unspecified), 1 (keyCompromise), 2 (cACompromise), 3 (affiliationChanged)," + - " 4 (superseded), 5 (cessationOfOperation), 6 (certificateHold), 8 (removeFromCRL)," + - " 9 (privilegeWithdrawn), or 10 (aACompromise).", - Value: acme.CRLReasonUnspecified, - }, - ) - - return flags -} - func revoke(ctx context.Context, cmd *cli.Command) error { account, keyType := setupAccount(ctx, cmd, newAccountsStorage(cmd)) diff --git a/cmd/flags.go b/cmd/flags.go index f8afa2d61..74dc23e15 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -6,6 +6,7 @@ import ( "path/filepath" "time" + "github.com/go-acme/lego/v5/acme" "github.com/go-acme/lego/v5/certificate" "github.com/go-acme/lego/v5/cmd/internal/storage" "github.com/go-acme/lego/v5/lego" @@ -111,6 +112,12 @@ const ( flgForceCertDomains = "force-cert-domains" ) +// Flag names related to the specific revoke command. +const ( + flgKeep = "keep" + flgReason = "reason" +) + // Environment variable names. const ( envEAB = "LEGO_EAB" @@ -467,6 +474,30 @@ func createRenewFlags() []cli.Flag { return flags } +func createRevokeFlags() []cli.Flag { + flags := CreateBaseFlags() + + flags = append(flags, + &cli.BoolFlag{ + Name: flgKeep, + Aliases: []string{"k"}, + Usage: "Keep the certificates after the revocation instead of archiving them.", + }, + &cli.UintFlag{ + Name: flgReason, + Usage: "Identifies the reason for the certificate revocation." + + " See https://www.rfc-editor.org/rfc/rfc5280.html#section-5.3.1." + + " Valid values are:" + + " 0 (unspecified), 1 (keyCompromise), 2 (cACompromise), 3 (affiliationChanged)," + + " 4 (superseded), 5 (cessationOfOperation), 6 (certificateHold), 8 (removeFromCRL)," + + " 9 (privilegeWithdrawn), or 10 (aACompromise).", + Value: acme.CRLReasonUnspecified, + }, + ) + + return flags +} + func CreateDomainFlag() cli.Flag { return &cli.StringSliceFlag{ Name: flgDomains,