Skip to content

Commit cb52f9d

Browse files
authored
fix(core): add disableCheckVersion option to commands (#2983)
1 parent d163031 commit cb52f9d

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

internal/core/build_info.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ func (b *BuildInfo) GetUserAgent() string {
5757
}
5858

5959
func (b *BuildInfo) checkVersion(ctx context.Context) {
60-
if !b.IsRelease() || ExtractEnv(ctx, scwDisableCheckVersionEnv) == "true" {
60+
cmd := extractMeta(ctx).command
61+
cmdDisableCheckVersion := cmd != nil && cmd.DisableVersionCheck
62+
if !b.IsRelease() || ExtractEnv(ctx, scwDisableCheckVersionEnv) == "true" || cmdDisableCheckVersion {
6163
ExtractLogger(ctx).Debug("skipping check version")
6264
return
6365
}

internal/core/command.go

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ type Command struct {
3535
// DisableTelemetry disable telemetry for the command.
3636
DisableTelemetry bool
3737

38+
// DisableVersionCheck disable the version check to avoid superfluous message
39+
DisableVersionCheck bool
40+
3841
// Hidden hides the command form usage and auto-complete.
3942
Hidden bool
4043

internal/namespaces/autocomplete/autocomplete.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ import (
1919
)
2020

2121
func GetCommands() *core.Commands {
22-
return core.NewCommands(
22+
cmds := core.NewCommands(
2323
autocompleteRootCommand(),
2424
autocompleteInstallCommand(),
2525
autocompleteCompleteBashCommand(),
2626
autocompleteCompleteFishCommand(),
2727
autocompleteCompleteZshCommand(),
2828
autocompleteScriptCommand(),
2929
)
30+
31+
for _, cmd := range cmds.GetAll() {
32+
cmd.DisableVersionCheck = true
33+
}
34+
35+
return cmds
3036
}
3137

3238
func autocompleteRootCommand() *core.Command {

0 commit comments

Comments
 (0)