mirror of
https://github.com/go-acme/lego
synced 2026-03-14 14:35:48 +01:00
chore: remove global before
This commit is contained in:
parent
5e92a52c2e
commit
9ff5338937
6 changed files with 27 additions and 9 deletions
|
|
@ -20,8 +20,13 @@ const (
|
|||
|
||||
func createList() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "list",
|
||||
Usage: "Display certificates and accounts information.",
|
||||
Name: "list",
|
||||
Usage: "Display certificates and accounts information.",
|
||||
Before: func(ctx context.Context, cmd *cli.Command) (context.Context, error) {
|
||||
validatePathFlag(cmd)
|
||||
|
||||
return ctx, nil
|
||||
},
|
||||
Action: list,
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ func createRenew() *cli.Command {
|
|||
Usage: "Renew a certificate",
|
||||
Action: renew,
|
||||
Before: func(ctx context.Context, cmd *cli.Command) (context.Context, error) {
|
||||
validateFlags(cmd)
|
||||
|
||||
// we require either domains or csr, but not both
|
||||
hasDomains := len(cmd.StringSlice(flgDomains)) > 0
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,13 @@ const (
|
|||
|
||||
func createRevoke() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "revoke",
|
||||
Usage: "Revoke a certificate",
|
||||
Name: "revoke",
|
||||
Usage: "Revoke a certificate",
|
||||
Before: func(ctx context.Context, cmd *cli.Command) (context.Context, error) {
|
||||
validateFlags(cmd)
|
||||
|
||||
return ctx, nil
|
||||
},
|
||||
Action: revoke,
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ func createRun() *cli.Command {
|
|||
Name: "run",
|
||||
Usage: "Register an account, then create and install a certificate",
|
||||
Before: func(ctx context.Context, cmd *cli.Command) (context.Context, error) {
|
||||
validateFlags(cmd)
|
||||
|
||||
// we require either domains or csr, but not both
|
||||
hasDomains := len(cmd.StringSlice(flgDomains)) > 0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
|
|
@ -9,11 +8,19 @@ import (
|
|||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func Before(ctx context.Context, cmd *cli.Command) (context.Context, error) {
|
||||
// FIXME convert to flag requirement?
|
||||
func validatePathFlag(cmd *cli.Command) {
|
||||
if cmd.String(flgPath) == "" {
|
||||
log.Fatal(fmt.Sprintf("Could not determine the current working directory. Please pass --%s.", flgPath))
|
||||
}
|
||||
|
||||
// FIXME is command list need an existing path?
|
||||
}
|
||||
|
||||
// FIXME rename + remove fatal?
|
||||
func validateFlags(cmd *cli.Command) {
|
||||
validatePathFlag(cmd)
|
||||
|
||||
err := createNonExistingFolder(cmd.String(flgPath))
|
||||
if err != nil {
|
||||
log.Fatal("Could not check/create the path.",
|
||||
|
|
@ -26,6 +33,4 @@ func Before(ctx context.Context, cmd *cli.Command) (context.Context, error) {
|
|||
if cmd.String(flgServer) == "" {
|
||||
log.Fatal(fmt.Sprintf("Could not determine the current working server. Please pass --%s.", flgServer))
|
||||
}
|
||||
|
||||
return ctx, nil
|
||||
}
|
||||
|
|
@ -20,7 +20,6 @@ func main() {
|
|||
Version: getVersion(),
|
||||
EnableShellCompletion: true,
|
||||
Flags: cmd.CreateFlags(""),
|
||||
Before: cmd.Before,
|
||||
Commands: cmd.CreateCommands(),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue