| 51 | } |
| 52 | |
| 53 | func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Command { |
| 54 | opts := &EditOptions{ |
| 55 | IO: f.IOStreams, |
| 56 | HttpClient: f.HttpClient, |
| 57 | DetermineEditor: func() (string, error) { return cmdutil.DetermineEditor(f.Config) }, |
| 58 | FieldsToEditSurvey: prShared.FieldsToEditSurvey, |
| 59 | EditFieldsSurvey: prShared.EditFieldsSurvey, |
| 60 | FetchOptions: prShared.FetchOptions, |
| 61 | Prompter: f.Prompter, |
| 62 | } |
| 63 | |
| 64 | var bodyFile string |
| 65 | var removeMilestone bool |
| 66 | |
| 67 | cmd := &cobra.Command{ |
| 68 | Use: "edit {<numbers> | <urls>}", |
| 69 | Short: "Edit issues", |
| 70 | Long: heredoc.Docf(` |
| 71 | Edit one or more issues within the same repository. |
| 72 | |
| 73 | Editing issues' projects requires authorization with the %[1]sproject%[1]s scope. |
| 74 | To authorize, run %[1]sgh auth refresh -s project%[1]s. |
| 75 | |
| 76 | The %[1]s--add-assignee%[1]s and %[1]s--remove-assignee%[1]s flags both support |
| 77 | the following special values: |
| 78 | - %[1]s@me%[1]s: assign or unassign yourself |
| 79 | - %[1]s@copilot%[1]s: assign or unassign Copilot (not supported on GitHub Enterprise Server) |
| 80 | `, "`"), |
| 81 | Example: heredoc.Doc(` |
| 82 | $ gh issue edit 23 --title "I found a bug" --body "Nothing works" |
| 83 | $ gh issue edit 23 --add-label "bug,help wanted" --remove-label "core" |
| 84 | $ gh issue edit 23 --add-assignee "@me" --remove-assignee monalisa,hubot |
| 85 | $ gh issue edit 23 --add-assignee "@copilot" |
| 86 | $ gh issue edit 23 --add-project "Roadmap" --remove-project v1,v2 |
| 87 | $ gh issue edit 23 --milestone "Version 1" |
| 88 | $ gh issue edit 23 --remove-milestone |
| 89 | $ gh issue edit 23 --body-file body.txt |
| 90 | $ gh issue edit 23 34 --add-label "help wanted" |
| 91 | $ gh issue edit 23 --type Bug |
| 92 | $ gh issue edit 23 --remove-type |
| 93 | $ gh issue edit 23 --parent 100 |
| 94 | $ gh issue edit 23 --remove-parent |
| 95 | $ gh issue edit 100 --add-sub-issue 123,124 |
| 96 | $ gh issue edit 123 --add-blocked-by 200 --add-blocking 300,301 |
| 97 | `), |
| 98 | Args: cobra.MinimumNArgs(1), |
| 99 | RunE: func(cmd *cobra.Command, args []string) error { |
| 100 | issueNumbers, baseRepo, err := issueShared.ParseIssuesFromArgs(args) |
| 101 | if err != nil { |
| 102 | return err |
| 103 | } |
| 104 | |
| 105 | // If the args provided the base repo then use that directly. |
| 106 | if baseRepo, present := baseRepo.Value(); present { |
| 107 | opts.BaseRepo = func() (ghrepo.Interface, error) { |
| 108 | return baseRepo, nil |
| 109 | } |
| 110 | } else { |