github.com/zaquestion/lab@v0.25.1/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  	Aliases:          []string{"i"},
    10  	Short:            `Describe, list, and create issues`,
    11  	Long:             ``,
    12  	PersistentPreRun: labPersistentPreRun,
    13  	Run: func(cmd *cobra.Command, args []string) {
    14  		if list, _ := cmd.Flags().GetBool("list"); list {
    15  			issueListCmd.Run(cmd, args)
    16  			return
    17  		}
    18  
    19  		if browse, _ := cmd.Flags().GetBool("browse"); browse {
    20  			issueBrowseCmd.Run(cmd, args)
    21  			return
    22  		}
    23  
    24  		if id, _ := cmd.Flags().GetString("close"); id != "" {
    25  			issueCloseCmd.Run(cmd, append(args, id))
    26  			return
    27  		}
    28  
    29  		if len(args) == 0 || len(args) > 2 {
    30  			cmd.Help()
    31  			return
    32  		}
    33  
    34  		issueShowCmd.Run(cmd, args)
    35  	},
    36  }
    37  
    38  func init() {
    39  	issueCmd.Flags().BoolP("list", "l", false, "list issues on a remote")
    40  	issueCmd.Flags().MarkDeprecated("list", "use the \"list\" subcommand instead")
    41  	issueCmd.Flags().BoolP("browse", "b", false, "view issue <id> in a browser")
    42  	issueCmd.Flags().MarkDeprecated("browse", "use the \"browse\" subcommand instead")
    43  	issueCmd.Flags().StringP("close", "d", "", "close issue <id> on remote")
    44  	issueCmd.Flags().MarkDeprecated("close", "use the \"close\" subcommand instead")
    45  	RootCmd.AddCommand(issueCmd)
    46  }