Skip to content

Commit

Permalink
cmd: export CaddyVersion(), Commands() (#4316)
Browse files Browse the repository at this point in the history
* cmd: Export CaddyVersion()

* cmd: Add getter Commands()
  • Loading branch information
pymnh committed Sep 2, 2021
1 parent 105dac8 commit 9f6393c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/commandfuncs.go
Expand Up @@ -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
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/commands.go
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions cmd/main.go
Expand Up @@ -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)
Expand All @@ -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 != "" {
Expand Down

0 comments on commit 9f6393c

Please sign in to comment.