diff --git a/cmd/root.go b/cmd/root.go index 59618604..40ebfd81 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -66,7 +66,7 @@ var langs = map[string]string{ "SUI Template Engine": "SUI 模板引擎命令", } -// L 多语言切换 +// L Language switch func L(words string) string { if lang == "" { return words @@ -126,11 +126,14 @@ var suiCmd = &cobra.Command{ }, } -// 加载命令 +// Command initialize func init() { studioCmd.AddCommand(studio.RunCmd) + + // Sui suiCmd.AddCommand(sui.WatchCmd) + suiCmd.AddCommand(sui.BuildCmd) rootCmd.AddCommand( versionCmd, @@ -154,7 +157,7 @@ func init() { rootCmd.PersistentFlags().StringVarP(&licenseKey, "key", "k", "", L("Application license key")) } -// Execute 运行Root +// Execute Command func Execute() { if err := rootCmd.Execute(); err != nil { fmt.Fprintln(os.Stderr, err) @@ -162,7 +165,7 @@ func Execute() { } } -// Boot 设定配置 +// Boot Setting func Boot() { root := config.Conf.Root diff --git a/cmd/sui/build.go b/cmd/sui/build.go new file mode 100644 index 00000000..cfca8acd --- /dev/null +++ b/cmd/sui/build.go @@ -0,0 +1,89 @@ +package sui + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/fatih/color" + "github.com/google/uuid" + jsoniter "github.com/json-iterator/go" + "github.com/spf13/cobra" + "github.com/yaoapp/gou/session" + "github.com/yaoapp/yao/config" + "github.com/yaoapp/yao/engine" + "github.com/yaoapp/yao/sui/core" +) + +// BuildCmd command +var BuildCmd = &cobra.Command{ + Use: "build", + Short: L("Build the template"), + Long: L("Build the template"), + Run: func(cmd *cobra.Command, args []string) { + if len(args) < 2 { + fmt.Fprintln(os.Stderr, color.RedString(L("yao cui watch