Skip to content

Commit

Permalink
Don't ask about metrics for completion command
Browse files Browse the repository at this point in the history
fix #1206
  • Loading branch information
Mouradif committed Dec 9, 2023
1 parent 2428aeb commit 7f28240
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func createApp(cmd *cobra.Command, _ []string) error {
if err := migrations.RunMigrations(app); err != nil {
return err
}
if os.Getenv("RUN_E2E") == "" && !app.Conf.ConfigFileExists() && !utils.FileExists(utils.UserHomePath(constants.OldMetricsConfigFileName)) {
if os.Getenv("RUN_E2E") == "" && !app.Conf.ConfigFileExists() && !utils.FileExists(utils.UserHomePath(constants.OldMetricsConfigFileName)) && metrics.CheckCommandIsNotCompletion(cmd) {
err = metrics.HandleUserMetricsPreference(app)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ func userIsOptedIn(app *application.Avalanche) bool {

func HandleTracking(cmd *cobra.Command, app *application.Avalanche, flags map[string]string) {
if userIsOptedIn(app) {
if !cmd.HasSubCommands() && checkCommandIsNotCompletion(cmd) {
if !cmd.HasSubCommands() && CheckCommandIsNotCompletion(cmd) {
TrackMetrics(cmd, flags)
}
}
}

func checkCommandIsNotCompletion(cmd *cobra.Command) bool {
func CheckCommandIsNotCompletion(cmd *cobra.Command) bool {
result := strings.Fields(cmd.CommandPath())
if len(result) >= 2 && result[1] == "completion" {
return false
Expand Down

0 comments on commit 7f28240

Please sign in to comment.