From f4df45c9ca26ca8207f14cee46ccf3859efc084c Mon Sep 17 00:00:00 2001 From: neil Date: Fri, 22 May 2026 16:42:27 +0200 Subject: [PATCH] implement XCADDY_PRINT_VERSION env variable --- README.md | 1 + cmd/commands.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 638675c..a671877 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,7 @@ Because the subcommands and flags are constrained to benefit rapid plugin protot - `XCADDY_WHICH_GO` sets the go command to use when for example more then 1 version of go is installed. - `XCADDY_GO_BUILD_FLAGS` overrides default build arguments. Supports Unix-style shell quoting, for example: XCADDY_GO_BUILD_FLAGS="-ldflags '-w -s'". The provided flags are applied to `go` commands: build, clean, get, install, list, run, and test - `XCADDY_GO_MOD_FLAGS` overrides default `go mod` arguments. Supports Unix-style shell quoting. +- `XCADDY_PRINT_VERSION` prints the Caddy version after building to prove the build is working (defaults to 1). --- diff --git a/cmd/commands.go b/cmd/commands.go index cf94adc..da84b4d 100644 --- a/cmd/commands.go +++ b/cmd/commands.go @@ -180,8 +180,10 @@ Flags: return err } + var printVersion = os.Getenv("XCADDY_PRINT_VERSION") != "0" + // prove the build is working by printing the version - if runtime.GOOS == utils.GetGOOS() && runtime.GOARCH == utils.GetGOARCH() { + if printVersion && runtime.GOOS == utils.GetGOOS() && runtime.GOARCH == utils.GetGOARCH() { if !filepath.IsAbs(output) { output = "." + string(filepath.Separator) + output }