mod 命令完善
This commit is contained in:
+17
-4
@@ -1,13 +1,17 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"complie-erlang/config"
|
||||
"complie-erlang/parser/zm_lib"
|
||||
"complie-erlang/worker"
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"log"
|
||||
)
|
||||
|
||||
type modSet struct{}
|
||||
type modSet struct {
|
||||
author string
|
||||
}
|
||||
|
||||
func (m *modSet) run(cmd *cobra.Command, args []string) {
|
||||
if len(args) == 0 {
|
||||
@@ -17,7 +21,14 @@ func (m *modSet) run(cmd *cobra.Command, args []string) {
|
||||
modName := args[0]
|
||||
modArgs := args[1:]
|
||||
|
||||
if err := worker.ModWorkerRun(modName, modArgs); err != nil {
|
||||
var DefaultArgs []config.DefaultArg
|
||||
|
||||
DefaultArgs = append(DefaultArgs, config.DefaultArg{
|
||||
Key: "Author",
|
||||
Value: m.author,
|
||||
})
|
||||
|
||||
if err := worker.ModWorkerRun(modName, modArgs, DefaultArgs); err != nil {
|
||||
log.Printf("[error] mod worker run error: %v", err)
|
||||
}
|
||||
|
||||
@@ -32,13 +43,15 @@ func init() {
|
||||
Long: `
|
||||
- 根据约定模板生成
|
||||
|
||||
mod activity activity_test.proto
|
||||
mod func test1.proto
|
||||
mod activity activity_test
|
||||
mod func test1
|
||||
|
||||
`,
|
||||
Run: singleSet.run,
|
||||
}
|
||||
|
||||
_ = zm_lib.PersistentFlagsStringVar(singleCmd, &singleSet.author, globalCache, "author", "st,sutong@youkia.net", "作者")
|
||||
|
||||
rootCmd.AddCommand(singleCmd)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user