github.com/zaquestion/lab@v0.25.1/cmd/issue_reopen.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "github.com/MakeNowJust/heredoc/v2" 6 7 "github.com/rsteube/carapace" 8 "github.com/spf13/cobra" 9 "github.com/zaquestion/lab/internal/action" 10 lab "github.com/zaquestion/lab/internal/gitlab" 11 ) 12 13 var issueReopenCmd = &cobra.Command{ 14 Use: "reopen [remote] <id>", 15 Short: "Reopen a closed issue", 16 Example: heredoc.Doc(` 17 lab issue reopen 1 18 lab issue reopen upstream 2`), 19 PersistentPreRun: labPersistentPreRun, 20 Run: func(cmd *cobra.Command, args []string) { 21 rn, id, err := parseArgsRemoteAndID(args) 22 if err != nil { 23 log.Fatal(err) 24 } 25 26 err = lab.IssueReopen(rn, int(id)) 27 if err != nil { 28 log.Fatal(err) 29 } 30 fmt.Printf("Issue #%d reopened\n", id) 31 }, 32 } 33 34 func init() { 35 issueCmd.AddCommand(issueReopenCmd) 36 carapace.Gen(mrReopenCmd).PositionalCompletion( 37 action.Remotes(), 38 action.Issues(issueList), 39 ) 40 }