github.com/zaquestion/lab@v0.25.1/cmd/mr_reopen.go (about)

     1  package cmd
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/rsteube/carapace"
     7  	"github.com/spf13/cobra"
     8  	"github.com/zaquestion/lab/internal/action"
     9  	lab "github.com/zaquestion/lab/internal/gitlab"
    10  )
    11  
    12  var mrReopenCmd = &cobra.Command{
    13  	Use:              "reopen [remote] [<MR id or branch>]",
    14  	Short:            "Reopen a closed merge request",
    15  	Example:          "lab mr reopen upstream 20",
    16  	PersistentPreRun: labPersistentPreRun,
    17  	Run: func(cmd *cobra.Command, args []string) {
    18  		rn, id, err := parseArgsWithGitBranchMR(args)
    19  		if err != nil {
    20  			log.Fatal(err)
    21  		}
    22  
    23  		err = lab.MRReopen(rn, int(id))
    24  		if err != nil {
    25  			log.Fatal(err)
    26  		}
    27  		fmt.Printf("Merge Request !%d reopened\n", id)
    28  	},
    29  }
    30  
    31  func init() {
    32  	mrCmd.AddCommand(mrReopenCmd)
    33  	carapace.Gen(mrReopenCmd).PositionalCompletion(
    34  		action.Remotes(),
    35  		action.MergeRequests(mrList),
    36  	)
    37  }