mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-14 15:43:52 +08:00
8ccfedf2bb
Some checks are pending
Tests / test (./cmd/caddy/caddy, ~1.21.0, macos-14, 0, 1.21, mac) (push) Waiting to run
Tests / test (./cmd/caddy/caddy, ~1.21.0, ubuntu-latest, 0, 1.21, linux) (push) Waiting to run
Tests / test (./cmd/caddy/caddy, ~1.22.3, macos-14, 0, 1.22, mac) (push) Waiting to run
Tests / test (./cmd/caddy/caddy, ~1.22.3, ubuntu-latest, 0, 1.22, linux) (push) Waiting to run
Tests / test (./cmd/caddy/caddy.exe, ~1.21.0, windows-latest, True, 1.21, windows) (push) Waiting to run
Tests / test (./cmd/caddy/caddy.exe, ~1.22.3, windows-latest, True, 1.22, windows) (push) Waiting to run
Tests / test (s390x on IBM Z) (push) Waiting to run
Tests / goreleaser-check (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, aix) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, darwin) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, dragonfly) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, freebsd) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, illumos) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, linux) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, netbsd) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, openbsd) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, solaris) (push) Waiting to run
Cross-Build / build (~1.22.3, 1.22, windows) (push) Waiting to run
Lint / lint (macos-14, mac) (push) Waiting to run
Lint / lint (ubuntu-latest, linux) (push) Waiting to run
Lint / lint (windows-latest, windows) (push) Waiting to run
Lint / govulncheck (push) Waiting to run
Co-authored-by: Francis Lavoie <lavofr@gmail.com>
29 lines
523 B
Go
29 lines
523 B
Go
package caddycmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type rootCommandFactory struct {
|
|
constructor func() *cobra.Command
|
|
options []func(*cobra.Command)
|
|
}
|
|
|
|
func newRootCommandFactory(fn func() *cobra.Command) *rootCommandFactory {
|
|
return &rootCommandFactory{
|
|
constructor: fn,
|
|
}
|
|
}
|
|
|
|
func (f *rootCommandFactory) Use(fn func(cmd *cobra.Command)) {
|
|
f.options = append(f.options, fn)
|
|
}
|
|
|
|
func (f *rootCommandFactory) Build() *cobra.Command {
|
|
o := f.constructor()
|
|
for _, v := range f.options {
|
|
v(o)
|
|
}
|
|
return o
|
|
}
|