Browse Source

cmd: Print more detailed version with --environ

master
Matthew Holt 4 years ago
parent
commit
8f6f9865d4
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 14
      cmd/commandfuncs.go
  2. 21
      cmd/main.go

14
cmd/commandfuncs.go

@ -336,19 +336,7 @@ func cmdReload(fl Flags) (int, error) {
} }
func cmdVersion(_ Flags) (int, error) { func cmdVersion(_ Flags) (int, error) {
goModule := caddy.GoModule() fmt.Println(caddyVersion())
fmt.Print(goModule.Version)
if goModule.Sum != "" {
// a build with a known version will also have a checksum
fmt.Printf(" %s", goModule.Sum)
}
if goModule.Replace != nil {
fmt.Printf(" => %s", goModule.Replace.Path)
if goModule.Replace.Version != "" {
fmt.Printf(" %s", goModule.Replace.Version)
}
}
fmt.Println()
return caddy.ExitCodeSuccess, nil return caddy.ExitCodeSuccess, nil
} }

21
cmd/main.go

@ -415,7 +415,7 @@ func printEnvironment() {
fmt.Printf("caddy.AppDataDir=%s\n", caddy.AppDataDir()) fmt.Printf("caddy.AppDataDir=%s\n", caddy.AppDataDir())
fmt.Printf("caddy.AppConfigDir=%s\n", caddy.AppConfigDir()) fmt.Printf("caddy.AppConfigDir=%s\n", caddy.AppConfigDir())
fmt.Printf("caddy.ConfigAutosavePath=%s\n", caddy.ConfigAutosavePath) fmt.Printf("caddy.ConfigAutosavePath=%s\n", caddy.ConfigAutosavePath)
fmt.Printf("caddy.Version=%s\n", caddy.GoModule().Version) fmt.Printf("caddy.Version=%s\n", caddyVersion())
fmt.Printf("runtime.GOOS=%s\n", runtime.GOOS) fmt.Printf("runtime.GOOS=%s\n", runtime.GOOS)
fmt.Printf("runtime.GOARCH=%s\n", runtime.GOARCH) fmt.Printf("runtime.GOARCH=%s\n", runtime.GOARCH)
fmt.Printf("runtime.Compiler=%s\n", runtime.Compiler) fmt.Printf("runtime.Compiler=%s\n", runtime.Compiler)
@ -432,6 +432,25 @@ func printEnvironment() {
} }
} }
// caddyVersion returns a detailed version string, if available.
func caddyVersion() string {
goModule := caddy.GoModule()
ver := goModule.Version
if goModule.Sum != "" {
ver += " " + goModule.Sum
}
if goModule.Replace != nil {
ver += " => " + goModule.Replace.Path
if goModule.Replace.Version != "" {
ver += "@" + goModule.Replace.Version
}
if goModule.Replace.Sum != "" {
ver += " " + goModule.Replace.Sum
}
}
return ver
}
// moveStorage moves the old default dataDir to the new default dataDir. // moveStorage moves the old default dataDir to the new default dataDir.
// TODO: This is TEMPORARY until the release candidates. // TODO: This is TEMPORARY until the release candidates.
func moveStorage() { func moveStorage() {

Loading…
Cancel
Save