Repository navigation
8000
Expand file tree
/
Copy pathcreate.go
More file actions
85 lines (71 loc) · 2.09 KB
/
Copy pathcreate.go
File metadata and controls
85 lines (71 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<
9305
div data-line-number="39" class="react-line-number react-code-text" style="padding-right:16px">3940
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package cli
import (
"github.com/spf13/cobra"
"github.com/verless/verless/core"
)
// newCreateCmd creates the `verless create` command.
func newCreateCmd() *cobra.Command {
createCmd := cobra.Command{
Use: "create",
Short: `Create a new verless object`,
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}
createCmd.AddCommand(newCreateProjectCmd())
createCmd.AddCommand(newCreateThemeCmd())
createCmd.AddCommand(newCreateFile())
return &createCmd
}
// newCreateFile creates the `verless create file` command
func newCreateFile() *cobra.Command {
var (
options core.CreateFileOptions
)
createFileCmd := cobra.Command{
Use: "file NAME",
Short: `Create a new content file`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
path := args[0]
return core.CreateFile(path, options)
},
}
createFileCmd.Flags().StringVarP(&options.Project, "project", "p", ".", `project path to create file in.`)
return &createFileCmd
}
// newCreateProjectCmd creates the `verless create project` command.
func newCreateProjectCmd() *cobra.Command {
var (
options core.CreateProjectOptions
)
createProjectCmd := cobra.Command{
Use: "project NAME",
Short: `Create a new verless project`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
path := args[0]
return core.CreateProject(path, options)
},
}
createProjectCmd.Flags().BoolVar(&options.Overwrite, "overwrite",
false, `overwrite the directory if it already exists`)
return &createProjectCmd
}
// newCreateThemeCmd creates the `verless create theme` command.
func newCreateThemeCmd() *cobra.Command {
var (
options core.CreateThemeOptions
)
createThemeCmd := cobra.Command{
Use: "theme THEME_NAME",
Short: `Create a new verless theme`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
name := args[0]
return core.CreateTheme(options, name)
},
}
createThemeCmd.Flags().StringVarP(&options.Project, "project", "p", ".", `project path to create new theme in.`)
return &createThemeCmd
}