Skip to content

Commit f6400a9

Browse files
authored
Avoid upgrade message when running upgrade command (#1045)
* avoid upgrade msg when doing upgrade cmd * make function private
1 parent f589acc commit f6400a9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/cmd/cli/command/commands.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ var RootCmd = &cobra.Command{
336336
if v, err := client.GetVersions(cmd.Context()); err == nil {
337337
version := cmd.Root().Version // HACK to avoid circular dependency with RootCmd
338338
term.Debug("Fabric:", v.Fabric, "CLI:", version, "CLI-Min:", v.CliMin)
339-
if hasTty && isNewer(version, v.CliMin) {
339+
if hasTty && isNewer(version, v.CliMin) && !isUpgradeCommand(cmd) {
340340
term.Warn("Your CLI version is outdated. Please upgrade to the latest version by running:\n\n defang upgrade\n")
341341
os.Setenv("DEFANG_HIDE_UPDATE", "1") // hide the upgrade hint at the end
342342
}
@@ -1081,6 +1081,10 @@ func IsCompletionCommand(cmd *cobra.Command) bool {
10811081
return cmd.Name() == cobra.ShellCompRequestCmd || (cmd.Parent() != nil && cmd.Parent().Name() == "completion")
10821082
}
10831083

1084+
func isUpgradeCommand(cmd *cobra.Command) bool {
1085+
return cmd.Name() == "upgrade"
1086+
}
1087+
10841088
var providerDescription = map[cliClient.ProviderID]string{
10851089
cliClient.ProviderDefang: "The Defang Playground is a free platform intended for testing purposes only.",
10861090
cliClient.ProviderAWS: "Deploy to AWS using the AWS_* environment variables or the AWS CLI configuration.",

0 commit comments

Comments
 (0)