summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2021-01-16 12:52:33 -0700
committerMatthew Holt <[email protected]>2021-01-16 12:52:33 -0700
commit8f6f9865d49d044e2fdc5e97bb0cc4fac155162e (patch)
tree9ae3395a71c4cc7ff675c2ce942e74c0393b35b8 /cmd
parent58e83a811bce9a4f2bad0c3460939c54848becdf (diff)
downloadcaddy-8f6f9865d49d044e2fdc5e97bb0cc4fac155162e.tar.gz
caddy-8f6f9865d49d044e2fdc5e97bb0cc4fac155162e.zip
cmd: Print more detailed version with --environ
Diffstat (limited to 'cmd')
-rw-r--r--cmd/commandfuncs.go14
-rw-r--r--cmd/main.go21
2 files changed, 21 insertions, 14 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index 1ee7dd87c..bf24c240f 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -336,19 +336,7 @@ func cmdReload(fl Flags) (int, error) {
}
func cmdVersion(_ Flags) (int, error) {
- goModule := caddy.GoModule()
- 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()
+ fmt.Println(caddyVersion())
return caddy.ExitCodeSuccess, nil
}
diff --git a/cmd/main.go b/cmd/main.go
index 2dfb8677f..564343190 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -415,7 +415,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", caddy.GoModule().Version)
+ 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)
@@ -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.
// TODO: This is TEMPORARY until the release candidates.
func moveStorage() {