Summary
ACE uses urfave/cli/v3, which provides a built-in -v/--version flag via
cli.VersionFlag. However, the flag is only registered when the root
Command.Version field is set. ACE does not set it, so ace --version fails:
$ ace --version
Incorrect Usage: flag provided but not defined: -version
Current Workaround
The only way to determine the version today is inspecting Go build metadata:
$ go version -m /usr/bin/ace
mod github.com/pgedge/ace v1.9.1-0.20260525173524-40465f03d62e
This returns a pseudo-version, not a clean release identifier, and is not
practical for end users.
Proposed Fix
Since the framework already handles the flag, the change is minimal:
-
Add build-time version variables in the main package:
var (
version = "dev"
commit = "none"
date = "unknown"
)
-
Set the Version field on the root command:
cmd := &cli.Command{
Name: "ace",
Version: version,
// ...
}
-
(Optional) Customize the printer to include commit + build date:
cli.VersionPrinter = func(cmd *cli.Command) {
fmt.Printf("ACE %s (commit: %s, built: %s)\n", version, commit, date)
}
-
Inject values at build time via ldflags:
go build -ldflags "
-X main.version=$(git describe --tags)
-X main.commit=$(git rev-parse --short HEAD)
-X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
./cmd/ace
Expected Result
$ ace --version
ACE v1.9.1 (commit: 40465f0, built: 2026-05-25T17:35:24Z)
Benefits
- Uses framework's existing flag — no custom parsing
- Clean version for support, bug reports, and CI/CD
- Build metadata (commit/date) aids debugging pre-release builds
Summary
ACE uses urfave/cli/v3, which provides a built-in -v/--version flag via
cli.VersionFlag. However, the flag is only registered when the root
Command.Version field is set. ACE does not set it, so
ace --versionfails:$ ace --version
Incorrect Usage: flag provided but not defined: -version
Current Workaround
The only way to determine the version today is inspecting Go build metadata:
$ go version -m /usr/bin/ace
mod github.com/pgedge/ace v1.9.1-0.20260525173524-40465f03d62e
This returns a pseudo-version, not a clean release identifier, and is not
practical for end users.
Proposed Fix
Since the framework already handles the flag, the change is minimal:
Add build-time version variables in the main package:
var (
version = "dev"
commit = "none"
date = "unknown"
)
Set the Version field on the root command:
cmd := &cli.Command{
Name: "ace",
Version: version,
// ...
}
(Optional) Customize the printer to include commit + build date:
cli.VersionPrinter = func(cmd *cli.Command) {
fmt.Printf("ACE %s (commit: %s, built: %s)\n", version, commit, date)
}
Inject values at build time via ldflags:
go build -ldflags "
-X main.version=$(git describe --tags)
-X main.commit=$(git rev-parse --short HEAD)
-X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
./cmd/ace
Expected Result
$ ace --version
ACE v1.9.1 (commit: 40465f0, built: 2026-05-25T17:35:24Z)
Benefits