github.com/zaquestion/lab@v0.25.1/cmd/issue_unsubscribe.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 issueUnsubscribeCmd = &cobra.Command{ 13 Use: "unsubscribe [remote] <id>", 14 Aliases: []string{}, 15 Short: "Unubscribe from an issue", 16 Long: ``, 17 Example: "lab issue unsubscribe origin 10", 18 PersistentPreRun: labPersistentPreRun, 19 Run: func(cmd *cobra.Command, args []string) { 20 rn, id, err := parseArgsRemoteAndID(args) 21 if err != nil { 22 log.Fatal(err) 23 } 24 25 err = lab.IssueUnsubscribe(rn, int(id)) 26 if err != nil { 27 log.Fatal(err) 28 } 29 fmt.Printf("Unsubscribed from issue #%d\n", id) 30 }, 31 } 32 33 func init() { 34 issueCmd.AddCommand(issueUnsubscribeCmd) 35 carapace.Gen(issueUnsubscribeCmd).PositionalCompletion( 36 action.Remotes(), 37 action.Issues(issueList), 38 ) 39 }