github.com/azunymous/cdx@v0.0.0-20201122180449-fbb46cc4d252/commands/options/git.go (about)

     1  package options
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  )
     6  
     7  // Git struct contains options regarding git settings
     8  type Git struct {
     9  	Push         bool
    10  	HeadOnly     bool
    11  	FallbackHash bool
    12  }
    13  
    14  func AddPushArg(cmd *cobra.Command, g *Git) {
    15  	cmd.Flags().BoolVarP(&g.Push, "push", "p", false, "Push tags (must be on origin/master)")
    16  }
    17  
    18  func AddHeadOnlyArg(cmd *cobra.Command, g *Git) {
    19  	cmd.Flags().BoolVar(&g.HeadOnly, "head", false, "Look at tags at HEAD only")
    20  }
    21  
    22  func AddFallbackHashArg(cmd *cobra.Command, g *Git) {
    23  	cmd.Flags().BoolVar(&g.FallbackHash, "fallback", false, "Fallback to git hash of current commit if no tag found. Must be used with --head.")
    24  }