github.com/mutagen-io/mutagen@v0.18.0-rc1/cmd/completion.go (about)

     1  package cmd
     2  
     3  import (
     4  	"os"
     5  
     6  	"github.com/spf13/cobra"
     7  )
     8  
     9  // PerformingShellCompletion indicates whether or not one of Cobra's hidden
    10  // shell completion commands is being used.
    11  var PerformingShellCompletion bool
    12  
    13  func init() {
    14  	// Check if one of Cobra's hidden shell completion commands is being used.
    15  	PerformingShellCompletion = len(os.Args) > 1 &&
    16  		(os.Args[1] == cobra.ShellCompRequestCmd ||
    17  			os.Args[1] == cobra.ShellCompNoDescRequestCmd)
    18  }