code-intelligence.com/cifuzz@v0.40.0/internal/cmdutils/config_check.go (about)

     1  package cmdutils
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  )
     6  
     7  func DisableConfigCheck(cmd *cobra.Command) {
     8  	if cmd.Annotations == nil {
     9  		cmd.Annotations = map[string]string{}
    10  	}
    11  
    12  	cmd.Annotations["skipConfigCheck"] = "true"
    13  }
    14  
    15  func NeedsConfig(cmd *cobra.Command) bool {
    16  	switch cmd.Name() {
    17  	case "help", cobra.ShellCompRequestCmd, cobra.ShellCompNoDescRequestCmd:
    18  		return false
    19  	}
    20  	if cmd.Parent() != nil && cmd.Parent().Name() == "completion" {
    21  		return false
    22  	}
    23  
    24  	for c := cmd; c != nil; c = c.Parent() {
    25  		if c.Annotations != nil && c.Annotations["skipConfigCheck"] == "true" {
    26  			return false
    27  		}
    28  	}
    29  
    30  	return true
    31  }