Skip to content

feat(service): add -v version flag to print version and OS/arch info#53

Open
ranganath42 wants to merge 4 commits into
masterfrom
feat/silver-version-option
Open

feat(service): add -v version flag to print version and OS/arch info#53
ranganath42 wants to merge 4 commits into
masterfrom
feat/silver-version-option

Conversation

@ranganath42

Copy link
Copy Markdown
Contributor

Adds a -v (version) CLI flag to the Silver service binary to display version and OS/architecture details in standard Go format.

silver version <ver> <os>/<arch>

The version flag executes early before config loading, enabling quick host compatibility checks.

Examples.

  • macOS (Intel / Rosetta): silver version 1.0.0 darwin/amd64
  • Linux: silver version 1.7.0 linux/amd64
  • Windows: silver version 1.7.0 windows/amd64
  • Unversioned Dev Build: silver version dev darwin/arm64

@ranganath42
ranganath42 requested review from ImGarlic and hiroxy July 23, 2026 07:16
@ranganath42 ranganath42 self-assigned this Jul 23, 2026
@ranganath42
ranganath42 force-pushed the feat/silver-version-option branch from 1c5879c to ee629ef Compare July 23, 2026 07:23
Comment thread service/args.go Outdated
"delete": "uninstall",
"check": "validate",
"test": "validate",
"v": "version",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required? It's an abbreviation rather than an alias.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, not exactly an alias, but rather a short flag.

It's convenient, though. The options are to,

  • Explicitly normalize -v in normalizeArgs
  • Refactor to Go's standard flag package

I would like to postpone the refactor to a later pull request. Do you think explicitly handling -v in normalizeArgs is better?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you want to allow version or -v as the command-line flag to display the version.
However, if v is set to the aliases, "v" is also a valid argument.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I wanted to support the short flag v, just like with the updater. Currently, this is the easiest, even though it is not the most idiomatic way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the updater support the v? I thought it was -v.

I don't see the need for the v option. If -v should be supported as other command-line tools, we should use an approriate way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point. I'll remove both short flags (v/-v) and only keep version to match the rest of the subcommands in the service binary.

Comment thread service/main.go
Comment thread make.go Outdated
// 3. Fallback "dev" for unflagged local development builds.
func resolveVersion(flagVersion string) string {
if flagVersion != "" {
return strings.TrimPrefix(flagVersion, "v")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I don't think we should modify a specified value
  • Why SILVER_VERSION and SILVER_RELEASEE_TAG needs to be handled here. We don't provide a CI build.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. This is a convenient method for a CI/CD to embed the version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking is that if the environment varibale can be set, the comnad-line flag also can be set. Therefore, the version being embedded into a binarty doesn't need to be set via the environment variable.

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.

2 participants