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

Function NewCmdCreate

pkg/cmd/project/create/create.go:34–70  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(config createConfig) error)

Source from the content-addressed store, hash-verified

32}
33
34func NewCmdCreate(f *cmdutil.Factory, runF func(config createConfig) error) *cobra.Command {
35 opts := createOpts{}
36 createCmd := &cobra.Command{
37 Short: "Create a project",
38 Use: "create",
39 Example: heredoc.Doc(`
40 # Create a new project owned by login monalisa
41 $ gh project create --owner monalisa --title "a new project"
42 `),
43 RunE: func(cmd *cobra.Command, args []string) error {
44 client, err := client.New(f)
45 if err != nil {
46 return err
47 }
48
49 config := createConfig{
50 client: client,
51 opts: opts,
52 io: f.IOStreams,
53 }
54
55 // allow testing of the command without actually running it
56 if runF != nil {
57 return runF(config)
58 }
59 return runCreate(config)
60 },
61 }
62
63 createCmd.Flags().StringVar(&opts.title, "title", "", "Title for the project")
64 createCmd.Flags().StringVar(&opts.owner, "owner", "", "Login of the owner. Use \"@me\" for the current user.")
65 cmdutil.AddFormatFlags(createCmd, &opts.exporter)
66
67 _ = createCmd.MarkFlagRequired("title")
68
69 return createCmd
70}
71
72func runCreate(config createConfig) error {
73 canPrompt := config.io.CanPrompt()

Callers 1

TestNewCmdCreateFunction · 0.70

Calls 3

NewFunction · 0.92
AddFormatFlagsFunction · 0.92
runCreateFunction · 0.85

Tested by 1

TestNewCmdCreateFunction · 0.56