Skip to content

Commit ce9682a

Browse files
Boretsclaude
andauthored
Improve --version output with update check feedback (#252)
* Update version notification copy Improve the --version update notification: - Highlight new version in bold for visibility - Suggest `brew upgrade render` as primary update method - Link to docs for other installation options Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add "up to date" message for --version Show confirmation when CLI is already on the latest version, so users know the version check completed successfully. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Use generic upgrade instructions for version check Remove Mac-specific `brew upgrade render` command and link to docs instead, making the message appropriate for all platforms. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix broken InstallationInstructionsURL anchor link The docs page anchor changed from #1-install to #1-install-or-upgrade. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 17ebc47 commit ce9682a

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

cmd/root.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/render-oss/cli/pkg/cfg"
1616
"github.com/render-oss/cli/pkg/client"
17+
"github.com/render-oss/cli/pkg/client/version"
1718
"github.com/render-oss/cli/pkg/command"
1819
"github.com/render-oss/cli/pkg/config"
1920
"github.com/render-oss/cli/pkg/dependencies"
@@ -192,9 +193,36 @@ func setupRootCmdPersistentRun(deps *dependencies.Dependencies) {
192193
}
193194
}
194195

196+
// printVersionWithUpdateCheck prints the current version and checks for updates
197+
func printVersionWithUpdateCheck() {
198+
fmt.Printf("render v%s\n", cfg.Version)
199+
200+
vc := version.NewClient(cfg.RepoURL)
201+
newVersion, err := vc.NewVersionAvailable()
202+
if err == nil && newVersion != "" {
203+
fmt.Println()
204+
fmt.Println(lipgloss.NewStyle().Foreground(renderstyle.ColorWarning).
205+
Render(fmt.Sprintf("A new version is available: %s\n\nTo upgrade, see: %s",
206+
renderstyle.Bold("v"+newVersion),
207+
cfg.InstallationInstructionsURL)))
208+
} else if err == nil {
209+
fmt.Println()
210+
fmt.Println(lipgloss.NewStyle().Foreground(renderstyle.ColorOK).
211+
Render("You are using the latest version"))
212+
}
213+
}
214+
195215
// Execute adds all child commands to the root command and sets flags appropriately.
196216
// This is called by main.main(). It only needs to happen once to the rootCmd.
197217
func Execute() {
218+
// Check if version flag is explicitly requested before Cobra handles it
219+
for _, arg := range os.Args[1:] {
220+
if arg == "--version" || arg == "-v" {
221+
printVersionWithUpdateCheck()
222+
return
223+
}
224+
}
225+
198226
if err := SetupCommands(); err != nil {
199227
os.Exit(1)
200228
}

pkg/cfg/cfg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const RepoURL = "https://api.github.com/repos/render-oss/cli"
10-
const InstallationInstructionsURL = "https://render.com/docs/cli#1-install"
10+
const InstallationInstructionsURL = "https://render.com/docs/cli#1-install-or-upgrade"
1111

1212
var Version = "dev"
1313
var osInfo string

0 commit comments

Comments
 (0)