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

Function NewCmdCreate

pkg/cmd/issue/create/create.go:66–199  ·  view source on GitHub ↗
(f *cmdutil.Factory, telemetry ghtelemetry.InvocationRecorder, runF func(*CreateOptions) error)

Source from the content-addressed store, hash-verified

64}
65
66func NewCmdCreate(f *cmdutil.Factory, telemetry ghtelemetry.InvocationRecorder, runF func(*CreateOptions) error) *cobra.Command {
67 opts := &CreateOptions{
68 IO: f.IOStreams,
69 HttpClient: f.HttpClient,
70 Config: f.Config,
71 Browser: f.Browser,
72 Prompter: f.Prompter,
73
74 TitledEditSurvey: prShared.TitledEditSurvey(&prShared.UserEditor{Config: f.Config, IO: f.IOStreams}),
75 }
76
77 var bodyFile string
78
79 cmd := &cobra.Command{
80 Use: "create",
81 Short: "Create a new issue",
82 Long: heredoc.Docf(`
83 Create an issue on GitHub.
84
85 Use %[1]s--attach%[1]s to upload an image or video. The attachment is appended to the
86 body. 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 created with the
96 ones that succeeded. The command then exits with a non-zero status, but the new
97 issue's URL is still printed to stdout.
98
99 Adding an issue to projects requires authorization with the %[1]sproject%[1]s scope.
100 To authorize, run %[1]sgh auth refresh -s project%[1]s.
101
102 The %[1]s--assignee%[1]s flag supports the following special values:
103 - %[1]s@me%[1]s: assign yourself
104 - %[1]s@copilot%[1]s: assign Copilot (not supported on GitHub Enterprise Server)
105 `, "`"),
106 Example: heredoc.Doc(`
107 $ gh issue create --title "I found a bug" --body "Nothing works"
108 $ gh issue create --attach './login.png#The login error state'
109 $ gh issue create --attach ./before.png --attach ./after.png
110 $ gh issue create --label "bug,help wanted"
111 $ gh issue create --label bug --label "help wanted"
112 $ gh issue create --assignee monalisa,hubot
113 $ gh issue create --assignee "@me"
114 $ gh issue create --assignee "@copilot"
115 $ gh issue create --project "Roadmap"
116 $ gh issue create --template "Bug Report"
117 $ gh issue create --type Bug
118 $ gh issue create --parent 100
119 $ gh issue create --parent https://github.com/cli/go-gh/issues/42
120 $ gh issue create --blocked-by 200,201 --blocking 300
121 `),
122 Args: cmdutil.NoArgsQuoteReminder,
123 Aliases: []string{"new"},

Callers 2

TestNewCmdCreateFunction · 0.70

Calls 10

ReadFileFunction · 0.92
FlagErrorfFunction · 0.92
MutuallyExclusiveFunction · 0.92
BeginTelemetryFunction · 0.92
AddFlagFunction · 0.92
ChangedMethod · 0.80
CanPromptMethod · 0.80
UserAssetsMethod · 0.80
createRunFunction · 0.70
CountMethod · 0.45

Tested by 2

TestNewCmdCreateFunction · 0.56