diff options
author | peymaneh <80954461+pymnh@users.noreply.github.com> | 2021-09-02 02:08:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 18:08:02 -0600 |
commit | 9f6393c64cd8dc969358d47fb96410d8ee5c063d (patch) | |
tree | a00f8c3bc756cf82d26ca129cf0b76d78fabfac8 /cmd | |
parent | 105dac8c2a3e48ed3957a606322015138752efd2 (diff) |
cmd: export CaddyVersion(), Commands() (#4316)
* cmd: Export CaddyVersion()
* cmd: Add getter Commands()
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/commandfuncs.go | 2 | ||||
-rw-r--r-- | cmd/commands.go | 6 | ||||
-rw-r--r-- | cmd/main.go | 6 |
3 files changed, 10 insertions, 4 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index c456a81..8f1c68c 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -331,7 +331,7 @@ func cmdReload(fl Flags) (int, error) { } func cmdVersion(_ Flags) (int, error) { - fmt.Println(caddyVersion()) + fmt.Println(CaddyVersion()) return caddy.ExitCodeSuccess, nil } diff --git a/cmd/commands.go b/cmd/commands.go index 89c4fe4..ccb82b1 100644 --- a/cmd/commands.go +++ b/cmd/commands.go @@ -61,6 +61,12 @@ type Command struct { // any error that occurred. type CommandFunc func(Flags) (int, error) +// Commands returns a list of commands initialised by +// RegisterCommand +func Commands() map[string]Command { + return commands +} + var commands = make(map[string]Command) func init() { diff --git a/cmd/main.go b/cmd/main.go index deac87f..8a9a289 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -420,7 +420,7 @@ func printEnvironment() { fmt.Printf("caddy.AppDataDir=%s\n", caddy.AppDataDir()) fmt.Printf("caddy.AppConfigDir=%s\n", caddy.AppConfigDir()) fmt.Printf("caddy.ConfigAutosavePath=%s\n", caddy.ConfigAutosavePath) - fmt.Printf("caddy.Version=%s\n", caddyVersion()) + fmt.Printf("caddy.Version=%s\n", CaddyVersion()) fmt.Printf("runtime.GOOS=%s\n", runtime.GOOS) fmt.Printf("runtime.GOARCH=%s\n", runtime.GOARCH) fmt.Printf("runtime.Compiler=%s\n", runtime.Compiler) @@ -437,8 +437,8 @@ func printEnvironment() { } } -// caddyVersion returns a detailed version string, if available. -func caddyVersion() string { +// CaddyVersion returns a detailed version string, if available. +func CaddyVersion() string { goModule := caddy.GoModule() ver := goModule.Version if goModule.Sum != "" { |