github.com/nkprince007/lab@v0.6.2-0.20171218071646-19d68b56f403/cmd/issue.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  )
     6  
     7  var issueCmd = &cobra.Command{
     8  	Use:   "issue",
     9  	Short: `Describe, list, and create issues`,
    10  	Long:  ``,
    11  	Run: func(cmd *cobra.Command, args []string) {
    12  		if list, _ := cmd.Flags().GetBool("list"); list {
    13  			issueListCmd.Run(cmd, args)
    14  			return
    15  		}
    16  
    17  		if len(args) == 0 || len(args) > 2 {
    18  			cmd.Help()
    19  			return
    20  		}
    21  
    22  		issueShowCmd.Run(cmd, args)
    23  	},
    24  }
    25  
    26  func init() {
    27  	issueCmd.Flags().BoolP("list", "l", false, "list issues")
    28  	RootCmd.AddCommand(issueCmd)
    29  }