Skip to content

Commit

Permalink
fix(core): add disableCheckVersion option to commands (#2983)
Browse files Browse the repository at this point in the history
  • Loading branch information
Codelax authored Apr 3, 2023
1 parent d163031 commit cb52f9d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/core/build_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func (b *BuildInfo) GetUserAgent() string {
}

func (b *BuildInfo) checkVersion(ctx context.Context) {
if !b.IsRelease() || ExtractEnv(ctx, scwDisableCheckVersionEnv) == "true" {
cmd := extractMeta(ctx).command
cmdDisableCheckVersion := cmd != nil && cmd.DisableVersionCheck
if !b.IsRelease() || ExtractEnv(ctx, scwDisableCheckVersionEnv) == "true" || cmdDisableCheckVersion {
ExtractLogger(ctx).Debug("skipping check version")
return
}
Expand Down
3 changes: 3 additions & 0 deletions internal/core/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type Command struct {
// DisableTelemetry disable telemetry for the command.
DisableTelemetry bool

// DisableVersionCheck disable the version check to avoid superfluous message
DisableVersionCheck bool

// Hidden hides the command form usage and auto-complete.
Hidden bool

Expand Down
8 changes: 7 additions & 1 deletion internal/namespaces/autocomplete/autocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ import (
)

func GetCommands() *core.Commands {
return core.NewCommands(
cmds := core.NewCommands(
autocompleteRootCommand(),
autocompleteInstallCommand(),
autocompleteCompleteBashCommand(),
autocompleteCompleteFishCommand(),
autocompleteCompleteZshCommand(),
autocompleteScriptCommand(),
)

for _, cmd := range cmds.GetAll() {
cmd.DisableVersionCheck = true
}

return cmds
}

func autocompleteRootCommand() *core.Command {
Expand Down

0 comments on commit cb52f9d

Please sign in to comment.