feat: introduce version info & update command#24
Closed
Conversation
0a6f367 to
76070bc
Compare
cg-eesuhn
approved these changes
Apr 21, 2026
1e9f54d to
b735dbf
Compare
b735dbf to
f2f1417
Compare
fbf21b0 to
c56f82f
Compare
There was a problem hiding this comment.
Pull request overview
Introduces CLI version surfacing plus an update mechanism: a passive “update available” reminder on startup and a new cg update command to upgrade in-place.
Changes:
- Added
internal/updaterpackage to fetch/cache latest GitHub release and compare versions. - Added
cg updatecommand with install-method detection, confirmation prompt, and upgrade execution. - Updated welcome banner to show build version and added an update reminder helper; documented
cg updatein README.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/updater/checker.go | Implements cached update checks + version comparison utilities |
| internal/updater/checker_test.go | Adds unit tests for version comparison, cache behavior, and fetch behavior |
| cmd/update.go | Adds cg update command (method detection, confirmation, upgrade execution) |
| cmd/update_test.go | Adds tests for update command behavior around version fetching/validation |
| internal/display/banner.go | Shows version in welcome box header; adds update reminder output + padding fix |
| cmd/root.go | Plumbs version into welcome box and triggers update check on startup |
| README.md | Documents cg update and adds it to commands list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
khooihzhz
reviewed
Apr 27, 2026
… pre-release tags Move ValidVersion into the updater package so both the background Check and the update command share one regex. Check() and FetchLatest() now reject non-MAJOR.MINOR.PATCH tags (e.g. rc1 builds) before writing to cache. Also normalise version prefix display in version cmd and banner. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tection Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
khooihzhz
approved these changes
May 7, 2026
khooihzhz
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cg updatecommand to upgrade the CLI in-place, auto-detecting the install method (Homebrew,go install, or the install script) and prompting for confirmation before runningcgstartup: checks GitHub Releases and prints a one-liner hint when a newer version exists◆ CoinGecko CLI v1.2.3)Changes
internal/updater/checker.go(new)Core update-check logic extracted into its own package:
Check(currentVersion)— passive checker used at startup. Reads a 24-hour cache at~/.config/coingecko-cli/update_check.jsonbefore hitting the network; skips entirely whenCG_NO_UPDATE_CHECK=1is set, or when the build version isdev/empty (local builds). Times out at 2 s so it never blocks the prompt.FetchLatest()— explicit fetch used bycg update. 10 s timeout, updates the cache on success.vfrom the GitHub tag so version strings are compared uniformly (e.g."1.4.0").cmd/update.go(new)cg updatecommand:/Cellar/or/opt/homebrew/→ Homebrew;$GOBINprefix →go install; fallback →install.shscript). Can be overridden with--method homebrew|go|script.huh.NewConfirm(Charm ecosystem, consistent withcg auth). Exits cleanly onCtrl-C/ "No".internal/display/banner.goPrintWelcomeBoxnow accepts the buildversionstring and renders it in the header row.PrintUpdateReminder(current, latest)— new helper that writes the update nudge to stderr, respectingNO_COLOR.printColoredRowwas callinglen()on a string that may contain multi-byte runes (e.g.◆); replaced withutf8.RuneCountInStringso box borders align correctly on all terminals.cmd/root.goversionintoPrintWelcomeBox.updater.Checkafter printing the welcome box and surfaces the reminder if an update is available.Test plan
cg(no args) — welcome box shows current version in header; no update notice when already on latestcgon an older build (spoof version string) — update notice appears below the welcome boxCG_NO_UPDATE_CHECK=1 cg— no network call, no noticecg updatewhen already on latest — prints "Already up to date"cg updatewhen a newer version exists — shows current → latest, confirms, runs the correct install command for the detected methodcg update --method homebrew|go|script— overrides detection, runs expected commandcg update --method invalid— returns a clear error