MCPcopy Index your code
hub / github.com/cli/cli / NewCmdCreate

Function NewCmdCreate

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

Source from the content-addressed store, hash-verified

57}
58
59func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Command {
60 opts := &CreateOptions{
61 IO: f.IOStreams,
62 HttpClient: f.HttpClient,
63 Config: f.Config,
64 Browser: f.Browser,
65 Prompter: f.Prompter,
66
67 TitledEditSurvey: prShared.TitledEditSurvey(&prShared.UserEditor{Config: f.Config, IO: f.IOStreams}),
68 }
69
70 var bodyFile string
71
72 cmd := &cobra.Command{
73 Use: "create",
74 Short: "Create a new issue",
75 Long: heredoc.Docf(`
76 Create an issue on GitHub.
77
78 Adding an issue to projects requires authorization with the %[1]sproject%[1]s scope.
79 To authorize, run %[1]sgh auth refresh -s project%[1]s.
80
81 The %[1]s--assignee%[1]s flag supports the following special values:
82 - %[1]s@me%[1]s: assign yourself
83 - %[1]s@copilot%[1]s: assign Copilot (not supported on GitHub Enterprise Server)
84 `, "`"),
85 Example: heredoc.Doc(`
86 $ gh issue create --title "I found a bug" --body "Nothing works"
87 $ gh issue create --label "bug,help wanted"
88 $ gh issue create --label bug --label "help wanted"
89 $ gh issue create --assignee monalisa,hubot
90 $ gh issue create --assignee "@me"
91 $ gh issue create --assignee "@copilot"
92 $ gh issue create --project "Roadmap"
93 $ gh issue create --template "Bug Report"
94 $ gh issue create --type Bug
95 $ gh issue create --parent 100
96 $ gh issue create --parent https://github.com/cli/go-gh/issues/42
97 $ gh issue create --blocked-by 200,201 --blocking 300
98 `),
99 Args: cmdutil.NoArgsQuoteReminder,
100 Aliases: []string{"new"},
101 RunE: func(cmd *cobra.Command, args []string) error {
102 // support `-R, --repo` override
103 opts.BaseRepo = f.BaseRepo
104 opts.HasRepoOverride = cmd.Flags().Changed("repo")
105
106 var err error
107 opts.EditorMode, err = prShared.InitEditorMode(f, opts.EditorMode, opts.WebMode, opts.IO.CanPrompt())
108 if err != nil {
109 return err
110 }
111
112 titleProvided := cmd.Flags().Changed("title")
113 bodyProvided := cmd.Flags().Changed("body")
114 if bodyFile != "" {
115 b, err := cmdutil.ReadFile(bodyFile, opts.IO.In)
116 if err != nil {

Callers 2

TestNewCmdCreateFunction · 0.70

Calls 4

ReadFileFunction · 0.92
FlagErrorfFunction · 0.92
CanPromptMethod · 0.80
createRunFunction · 0.70

Tested by 2

TestNewCmdCreateFunction · 0.56