Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
cmd: Print more detailed version with --environ
Matthew Holt committed
Jan 16, 2021 at 12:52 UTC
8f6f9865d49d044e2fdc5e97bb0cc4fac155162e
2 files changed
+21
-14
cmd/commandfuncs.go
+1
-13
@@ -336,19 +336,7 @@ func cmdReload(fl Flags) (int, error) {
336
}
337
338
func cmdVersion(_ Flags) (int, error) {
339
- goModule := caddy.GoModule()
340
- fmt.Print(goModule.Version)
341
- if goModule.Sum != "" {
342
- // a build with a known version will also have a checksum
343
- fmt.Printf(" %s", goModule.Sum)
344
- }
345
- if goModule.Replace != nil {
346
- fmt.Printf(" => %s", goModule.Replace.Path)
347
- if goModule.Replace.Version != "" {
348
- fmt.Printf(" %s", goModule.Replace.Version)
349
- }
350
- }
351
- fmt.Println()
339
+ fmt.Println(caddyVersion())
340
return caddy.ExitCodeSuccess, nil
341
}
342
cmd/main.go
+20
-1
@@ -415,7 +415,7 @@ func printEnvironment() {
415
fmt.Printf("caddy.AppDataDir=%s\n", caddy.AppDataDir())
416
fmt.Printf("caddy.AppConfigDir=%s\n", caddy.AppConfigDir())
417
fmt.Printf("caddy.ConfigAutosavePath=%s\n", caddy.ConfigAutosavePath)
418
- fmt.Printf("caddy.Version=%s\n", caddy.GoModule().Version)
418
+ fmt.Printf("caddy.Version=%s\n", caddyVersion())
419
fmt.Printf("runtime.GOOS=%s\n", runtime.GOOS)
420
fmt.Printf("runtime.GOARCH=%s\n", runtime.GOARCH)
421
fmt.Printf("runtime.Compiler=%s\n", runtime.Compiler)
@@ -432,6 +432,25 @@ func printEnvironment() {
432
}
433
}
434
435
+// caddyVersion returns a detailed version string, if available.
436
+func caddyVersion() string {
437
+ goModule := caddy.GoModule()
438
+ ver := goModule.Version
439
+ if goModule.Sum != "" {
440
+ ver += " " + goModule.Sum
441
+ }
442
+ if goModule.Replace != nil {
443
+ ver += " => " + goModule.Replace.Path
444
+ if goModule.Replace.Version != "" {
445
+ ver += "@" + goModule.Replace.Version
446
+ }
447
+ if goModule.Replace.Sum != "" {
448
+ ver += " " + goModule.Replace.Sum
449
+ }
450
+ }
451
+ return ver
452
+}
453
+
454
// moveStorage moves the old default dataDir to the new default dataDir.
455
// TODO: This is TEMPORARY until the release candidates.
456
func moveStorage() {