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

Function NewCmdEdit

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

Source from the content-addressed store, hash-verified

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

Callers 1

TestNewCmdEditFunction · 0.70

Calls 14

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

Tested by 1

TestNewCmdEditFunction · 0.56