-
Notifications
You must be signed in to change notification settings - Fork 16
/
plugin_scaffold.go
42 lines (37 loc) · 1018 Bytes
/
plugin_scaffold.go
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
39
40
41
42
package cmd
import (
"github.com/gatewayd-io/gatewayd/plugin"
"github.com/spf13/cobra"
)
var (
pluginScaffoldInputFile string
pluginScaffoldOutputDir string
)
// pluginScaffoldCmd represents the scaffold command.
var pluginScaffoldCmd = &cobra.Command{
Use: "scaffold",
Short: "Scaffold a plugin and store the files into a directory",
Run: func(cmd *cobra.Command, _ []string) {
createdFiles, err := plugin.Scaffold(pluginScaffoldInputFile, pluginScaffoldOutputDir)
if err != nil {
cmd.Println("Scaffold failed: ", err)
return
}
cmd.Println("scaffold done")
cmd.Println("created files:")
for _, file := range createdFiles {
cmd.Println(file)
}
},
}
func init() {
pluginCmd.AddCommand(pluginScaffoldCmd)
pluginScaffoldCmd.Flags().StringVarP(
&pluginScaffoldInputFile,
"input-file", "i", "input.yaml",
"Plugin scaffold input file")
pluginScaffoldCmd.Flags().StringVarP(
&pluginScaffoldOutputDir,
"output-dir", "o", "./plugins",
"Output directory for the scaffold")
}