github.com/zaquestion/lab@v0.25.1/cmd/issue_move.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "strconv" 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 issueMoveCmd = &cobra.Command{ 14 Use: "move <id> <destination>", 15 Short: "Move issue to another project", 16 Long: ``, 17 Example: "lab issue move 5 zaquestion/test/ # FQDN must match", 18 Args: cobra.MinimumNArgs(2), 19 PersistentPreRun: labPersistentPreRun, 20 Run: func(cmd *cobra.Command, args []string) { 21 // get this rn 22 srcRN, err := getRemoteName(defaultRemote) 23 if err != nil { 24 log.Fatal(err) 25 } 26 27 // get the issue ID 28 id, err := strconv.Atoi(args[0]) 29 if err != nil { 30 log.Fatal(err) 31 } 32 33 // get the dest rn (everything after gitlab.com/, for example, 34 destRN := args[1] 35 36 issueURL, err := lab.MoveIssue(srcRN, id, destRN) 37 if err != nil { 38 log.Fatal(err) 39 } 40 fmt.Println("Issue moved to:", issueURL) 41 }, 42 } 43 44 func init() { 45 issueCmd.AddCommand(issueMoveCmd) 46 carapace.Gen(issueMoveCmd).PositionalCompletion( 47 action.Remotes(), 48 action.Issues(issueList), 49 ) 50 }