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

Function NewCmdCreate

pkg/cmd/issue/create/create.go:64–196  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*CreateOptions) error)

Source from the content-addressed store, hash-verified

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

Callers 2

TestNewCmdCreateFunction · 0.70

Calls 8

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

Tested by 2

TestNewCmdCreateFunction · 0.56