MCPcopy Create free account
hub / github.com/cli/cli / NewCmdEdit

Function NewCmdEdit

pkg/cmd/issue/edit/edit.go:60–276  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*EditOptions) error)

Source from the content-addressed store, hash-verified

58}
59
60func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Command {
61 opts := &EditOptions{
62 IO: f.IOStreams,
63 HttpClient: f.HttpClient,
64 Config: f.Config,
65 DetermineEditor: func() (string, error) { return cmdutil.DetermineEditor(f.Config) },
66 FieldsToEditSurvey: prShared.FieldsToEditSurvey,
67 EditFieldsSurvey: prShared.EditFieldsSurvey,
68 FetchOptions: prShared.FetchOptions,
69 Prompter: f.Prompter,
70 }
71
72 var bodyFile string
73 var removeMilestone bool
74
75 cmd := &cobra.Command{
76 Use: "edit {<numbers> | <urls>}",
77 Short: "Edit issues",
78 Long: heredoc.Docf(`
79 Edit one or more issues within the same repository.
80
81 Editing issues' projects requires authorization with the %[1]sproject%[1]s scope.
82 To authorize, run %[1]sgh auth refresh -s project%[1]s.
83
84 Use %[1]s--attach%[1]s to upload an image or video to a single issue. Without a body
85 flag the issue keeps the body it already has and the attachment is appended to it.
86 If the body references an attached file, such as %[1]s![alt](./login.png)%[1]s, that
87 reference is rewritten to point at the uploaded asset instead.
88 You can attach up to 50 files per command.
89
90 Alt text for an image follows the path after %[1]s#%[1]s, as in
91 %[1]s--attach './login.png#The login error state'%[1]s. Without it the filename is used.
92 A reference already in the body keeps the alt text written there. Video renders
93 as a player and has no alt text, so it cannot be given any.
94
95 If some attachments upload and others fail, the issue is still updated with the
96 ones that succeeded. The command then exits with a non-zero status, but the edited
97 issue URLs are still printed to stdout.
98
99 The %[1]s--add-assignee%[1]s and %[1]s--remove-assignee%[1]s flags both support
100 the following special values:
101 - %[1]s@me%[1]s: assign or unassign yourself
102 - %[1]s@copilot%[1]s: assign or unassign Copilot (not supported on GitHub Enterprise Server)
103 `, "`"),
104 Example: heredoc.Doc(`
105 $ gh issue edit 23 --title "I found a bug" --body "Nothing works"
106 $ gh issue edit 23 --add-label "bug,help wanted" --remove-label "core"
107 $ gh issue edit 23 --add-assignee "@me" --remove-assignee monalisa,hubot
108 $ gh issue edit 23 --add-assignee "@copilot"
109 $ gh issue edit 23 --add-project "Roadmap" --remove-project v1,v2
110 $ gh issue edit 23 --milestone "Version 1"
111 $ gh issue edit 23 --remove-milestone
112 $ gh issue edit 23 --body-file body.txt
113 $ gh issue edit 23 --attach './login.png#The login error state'
114 $ gh issue edit 23 --attach ./before.png --attach ./after.png
115 $ gh issue edit 23 34 --add-label "help wanted"
116 $ gh issue edit 23 --type Bug
117 $ gh issue edit 23 --remove-type

Callers 1

TestNewCmdEditFunction · 0.70

Calls 12

hasDeferredEditsMethod · 0.95
DetermineEditorFunction · 0.92
MutuallyExclusiveFunction · 0.92
ReadFileFunction · 0.92
FlagErrorfFunction · 0.92
AddFlagFunction · 0.92
ValueMethod · 0.80
ChangedMethod · 0.80
UserAssetsMethod · 0.80
DirtyMethod · 0.80
CanPromptMethod · 0.80
editRunFunction · 0.70

Tested by 1

TestNewCmdEditFunction · 0.56