feat: introduce version info & update command#25
Merged
Conversation
khooihzhz
approved these changes
May 7, 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>
1d31f0a to
67ba05a
Compare
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