(f *cmdutil.Factory, runF func(*UnpinOptions) error)
| 25 | } |
| 26 | |
| 27 | func NewCmdUnpin(f *cmdutil.Factory, runF func(*UnpinOptions) error) *cobra.Command { |
| 28 | opts := &UnpinOptions{ |
| 29 | IO: f.IOStreams, |
| 30 | HttpClient: f.HttpClient, |
| 31 | Config: f.Config, |
| 32 | BaseRepo: f.BaseRepo, |
| 33 | } |
| 34 | |
| 35 | cmd := &cobra.Command{ |
| 36 | Use: "unpin {<number> | <url>}", |
| 37 | Short: "Unpin an issue", |
| 38 | Long: heredoc.Doc(` |
| 39 | Unpin an issue from a repository. |
| 40 | |
| 41 | The issue can be specified by issue number or URL. |
| 42 | `), |
| 43 | Example: heredoc.Doc(` |
| 44 | # Unpin issue from the current repository |
| 45 | $ gh issue unpin 23 |
| 46 | |
| 47 | # Unpin issue by URL |
| 48 | $ gh issue unpin https://github.com/owner/repo/issues/23 |
| 49 | |
| 50 | # Unpin an issue from specific repository |
| 51 | $ gh issue unpin 23 --repo owner/repo |
| 52 | `), |
| 53 | Args: cobra.ExactArgs(1), |
| 54 | RunE: func(cmd *cobra.Command, args []string) error { |
| 55 | issueNumber, baseRepo, err := shared.ParseIssueFromArg(args[0]) |
| 56 | if err != nil { |
| 57 | return err |
| 58 | } |
| 59 | |
| 60 | // If the args provided the base repo then use that directly. |
| 61 | if baseRepo, present := baseRepo.Value(); present { |
| 62 | opts.BaseRepo = func() (ghrepo.Interface, error) { |
| 63 | return baseRepo, nil |
| 64 | } |
| 65 | } else { |
| 66 | // support `-R, --repo` override |
| 67 | opts.BaseRepo = f.BaseRepo |
| 68 | } |
| 69 | |
| 70 | opts.IssueNumber = issueNumber |
| 71 | |
| 72 | if runF != nil { |
| 73 | return runF(opts) |
| 74 | } |
| 75 | |
| 76 | return unpinRun(opts) |
| 77 | }, |
| 78 | } |
| 79 | |
| 80 | return cmd |
| 81 | } |
| 82 | |
| 83 | func unpinRun(opts *UnpinOptions) error { |
| 84 | cs := opts.IO.ColorScheme() |
nothing calls this directly
no test coverage detected