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

Function NewCmdCreate

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

Source from the content-addressed store, hash-verified

63}
64
65func NewCmdCreate(f *cmdutil.Factory, telemetry ghtelemetry.CommandRecorder, runF func(*CreateOptions) error) *cobra.Command {
66 opts := &CreateOptions{
67 IO: f.IOStreams,
68 HttpClient: f.HttpClient,
69 Config: f.Config,
70 Browser: f.Browser,
71 Prompter: f.Prompter,
72
73 TitledEditSurvey: prShared.TitledEditSurvey(&prShared.UserEditor{Config: f.Config, IO: f.IOStreams}),
74 }
75
76 var bodyFile string
77
78 cmd := &cobra.Command{
79 Use: "create",
80 Short: "Create a new issue",
81 Long: heredoc.Docf(`
82 Create an issue on GitHub.
83
84 Use %[1]s--attach%[1]s to upload an image or video. The attachment is appended to the
85 body. If the body references an attached file, such as %[1]s![alt](./login.png)%[1]s, that
86 reference is rewritten to point at the uploaded asset instead.
87 You can attach up to 50 files per command.
88
89 Alt text for an image follows the path after %[1]s#%[1]s, as in
90 %[1]s--attach './login.png#The login error state'%[1]s. Without it the filename is used.
91 A reference already in the body keeps the alt text written there. Video renders
92 as a player and has no alt text, so it cannot be given any.
93
94 If some attachments upload and others fail, the issue is still created with the
95 ones that succeeded. The command then exits with a non-zero status, but the new
96 issue's URL is still printed to stdout.
97
98 Adding an issue to projects requires authorization with the %[1]sproject%[1]s scope.
99 To authorize, run %[1]sgh auth refresh -s project%[1]s.
100
101 The %[1]s--assignee%[1]s flag supports the following special values:
102 - %[1]s@me%[1]s: assign yourself
103 - %[1]s@copilot%[1]s: assign Copilot (not supported on GitHub Enterprise Server)
104 `, "`"),
105 Example: heredoc.Doc(`
106 $ gh issue create --title "I found a bug" --body "Nothing works"
107 $ gh issue create --attach './login.png#The login error state'
108 $ gh issue create --attach ./before.png --attach ./after.png
109 $ gh issue create --label "bug,help wanted"
110 $ gh issue create --label bug --label "help wanted"
111 $ gh issue create --assignee monalisa,hubot
112 $ gh issue create --assignee "@me"
113 $ gh issue create --assignee "@copilot"
114 $ gh issue create --project "Roadmap"
115 $ gh issue create --template "Bug Report"
116 $ gh issue create --type Bug
117 $ gh issue create --parent 100
118 $ gh issue create --parent https://github.com/cli/go-gh/issues/42
119 $ gh issue create --blocked-by 200,201 --blocking 300
120 `),
121 Args: cmdutil.NoArgsQuoteReminder,
122 Aliases: []string{"new"},

Callers 2

TestNewCmdCreateFunction · 0.70

Calls 9

ReadFileFunction · 0.92
FlagErrorfFunction · 0.92
MutuallyExclusiveFunction · 0.92
AddFlagFunction · 0.92
RecordTelemetryMethod · 0.80
ChangedMethod · 0.80
CanPromptMethod · 0.80
UserAssetsMethod · 0.80
createRunFunction · 0.70

Tested by 2

TestNewCmdCreateFunction · 0.56