Skip to content

feat(cli): add -v/--version flag - #295

Merged
0x2E merged 1 commit into
mainfrom
feat/add-version-flag
Nov 24, 2026
Merged

0x2E merged 1 commit into
mainfrom
feat/add-version-flag

Conversation

@0x2E

@0x2E 0x2E commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Summary

Adds -v / --version for automated updaters (#232). Flags are parsed before config loading, so it works with no FUSION_* env set.

 main
+  parseArgs(os.Args[1:])
+    -v / --version → print version, exit 0
+    unknown flag   → usage, exit 2
   run
     config.Load
     ...
-    slog.Info("starting server", "address", addr)
+    slog.Info("starting server", "address", addr, "version", version)

scripts.sh build_backend injects git describe --tags --always --dirty via -ldflags "-X main.version=..." (falls back to dev). Release and Docker builds already use this script with fetch-depth: 0, so CI is unchanged.

Build Output
Tagged release v1.3.2
main push image v1.3.2-1-ga153670
go run / plain go build dev

The --config request from #232 is intentionally not implemented: env files already cover it everywhere (docker --env-file, Compose env_file:, k8s envFrom, systemd EnvironmentFile=, set -a; . ./fusion.env), and a second config source would add precedence rules and dual maintenance for every option.

Evidence

  • Before: env -i ./fusion --version → ERROR fatal error="FUSION_PASSWORD or FUSION_OIDC_ISSUER is required ..." (exit 1)
    After: simulated release (scratch clone, commit tagged v9.9.9, build-frontend + build-backend, tree stays clean):

    $ env -i ./build/fusion --version   → v9.9.9   (exit 0)
    $ env -i ./build/fusion -v          → v9.9.9   (exit 0)
    $ env -i ./build/fusion --bogus     → usage    (exit 2)
    $ env -i ./build/fusion             → unchanged "FUSION_PASSWORD ... is required" (exit 1)
    startup log: {"msg":"starting server","address":":18123","version":"v9.9.9"}
    
  • TestParseArgs covers -v, --version, no args, unknown flag, -h; ./scripts.sh test-backend passes.

Merge Danger

Door: two-way

Blast Radius: small

Unknown flags (e.g. fusion -foo) used to be silently ignored and now exit 2. Non-flag positional args are still ignored.

Closes #232

🤖 Generated with Claude Code

Automated updaters need to know which version is installed. The binary
had no version information, and any invocation ran config.Load(), so it
failed without FUSION_PASSWORD or OIDC configured.

- Parse flags before loading config; `fusion -v` / `--version` prints
  the bare version to stdout and exits 0, so scripts can compare it with
  a release tag directly.
- build_backend injects `git describe --tags --always --dirty` via
  -X main.version, falling back to `dev`. Release and Docker builds
  already go through it with full history, so CI needs no change.
- Log the version on server start to help with bug reports.

Unknown flags now exit 2 with usage instead of being silently ignored.

Closes #232

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@0x2E
0x2E merged commit c0919d1 into main Nov 24, 2026
1 check passed
@0x2E 0x2E mentioned this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] CLI options

1 participant