github.com/nkprince007/lab@v0.6.2-0.20171218071646-19d68b56f403/cmd/mr.go (about) 1 package cmd 2 3 import ( 4 "github.com/spf13/cobra" 5 ) 6 7 // mrCmd represents the mr command 8 var mrCmd = &cobra.Command{ 9 Use: "mr", 10 Short: `Describe, list, and create merge requests`, 11 Long: ``, 12 Run: func(cmd *cobra.Command, args []string) { 13 if list, _ := cmd.Flags().GetBool("list"); list { 14 listCmd.Run(cmd, args) 15 return 16 } 17 18 if len(args) == 0 || len(args) > 2 { 19 cmd.Help() 20 return 21 } 22 23 mrShowCmd.Run(cmd, args) 24 }, 25 } 26 27 func init() { 28 mrCmd.Flags().BoolP("list", "l", false, "list MRs") 29 RootCmd.AddCommand(mrCmd) 30 }