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

Function NewCmdEdit

pkg/cmd/issue/edit/edit.go:61–279  ·  view source on GitHub ↗
(f *cmdutil.Factory, telemetry ghtelemetry.CommandRecorder, runF func(*EditOptions) error)

Source from the content-addressed store, hash-verified

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

Callers 1

TestNewCmdEditFunction · 0.70

Calls 13

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

Tested by 1

TestNewCmdEditFunction · 0.56