Skip to content

Commit 6c4b2a2

Browse files
gustavobertoiclaude
andcommitted
fix(cli): -v/--version shows the stamped version + version on top of help
fang's `-v`/`--version` derives from debug build info, which renders "unknown (built from source)" for an ldflags-stamped binary. Pass fang.WithVersion/WithCommit so it shows the real version+commit, and prepend the version to the root Long so it appears on top of the help banner. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bc843b4 commit 6c4b2a2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

internal/cli/root.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ func NewRootCmd(opts Options) *cobra.Command {
4343
root := &cobra.Command{
4444
Use: brand.Name,
4545
Short: "Docker-based dev environments with infrastructure shared across projects",
46-
Long: "devstack manages Docker-based development environments and shares infrastructure\n" +
46+
// The version is shown on top of the help banner (fang renders Long first).
47+
Long: brand.Name + " " + version.Version + "\n\n" +
48+
"devstack manages Docker-based development environments and shares infrastructure\n" +
4749
"(one warm Postgres/Redis/MinIO) across many project stacks in a workspace.",
4850
Version: version.String(),
4951
SilenceUsage: true, // fang renders errors; don't dump usage on every failure
@@ -79,9 +81,15 @@ func NewRootCmd(opts Options) *cobra.Command {
7981
return root
8082
}
8183

82-
// Execute wraps the root command with fang and runs it.
84+
// Execute wraps the root command with fang and runs it. The version/commit are
85+
// passed explicitly because fang's `-v`/`--version` derives from debug build info
86+
// otherwise — which renders "unknown (built from source)" for an ldflags-stamped
87+
// binary instead of our actual version.
8388
func Execute(ctx context.Context, root *cobra.Command) error {
84-
return fang.Execute(ctx, root)
89+
return fang.Execute(ctx, root,
90+
fang.WithVersion(version.Version),
91+
fang.WithCommit(version.Commit),
92+
)
8593
}
8694

8795
// setupLogging configures slog based on the global flags. --debug → Debug level

0 commit comments

Comments
 (0)