|
1 | 1 | package prj
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "github.com/apigear-io/cli/pkg/log" |
4 | 5 | "github.com/apigear-io/cli/pkg/prj"
|
5 | 6 |
|
6 | 7 | "github.com/spf13/cobra"
|
7 | 8 | )
|
8 | 9 |
|
9 |
| -func NewCreateCommand() *cobra.Command { |
10 |
| - var prjDir string |
| 10 | +// CreateProjectCommand returns a new cobra.Command for the "init" command. |
| 11 | +func CreateProjectCommand() *cobra.Command { |
| 12 | + var dir string |
11 | 13 | var cmd = &cobra.Command{
|
12 |
| - Use: "create doc-type doc-name", |
13 |
| - Short: "Create a new document inside current project", |
14 |
| - Long: `Create a new document inside current project from a template.`, |
15 |
| - Args: cobra.ExactArgs(2), |
| 14 | + Use: "create", |
| 15 | + Short: "create new project", |
| 16 | + Long: `create new project with default project files`, |
| 17 | + Args: cobra.NoArgs, |
16 | 18 | RunE: func(cmd *cobra.Command, args []string) error {
|
17 |
| - docType := args[0] |
18 |
| - name := args[1] |
19 |
| - target, err := prj.CreateProjectDocument(prjDir, docType, name) |
| 19 | + log.Debug().Msgf("create project in %s", dir) |
| 20 | + info, err := prj.InitProject(dir) |
20 | 21 | if err != nil {
|
21 | 22 | return err
|
22 | 23 | }
|
23 |
| - cmd.Printf("document %s created\n", target) |
| 24 | + cmd.Printf("project created at: %s\n", info.Path) |
24 | 25 | return nil
|
25 | 26 | },
|
26 | 27 | }
|
27 |
| - cmd.Flags().StringVarP(&prjDir, "project", "p", ".", "project directory") |
| 28 | + cmd.Flags().StringVarP(&dir, "dir", "d", ".", "project directory to create") |
| 29 | + cmd.MarkFlagRequired("dir") |
28 | 30 | return cmd
|
29 | 31 | }
|
0 commit comments