github.com/keysonZZZ/kmg@v0.0.0-20151121023212-05317bfd7d39/kmg/SubCommand/ParpareReflect.go.bak (about) 1 package command 2 3 /* 4 import ( 5 "os" 6 "path/filepath" 7 8 "github.com/bronze1man/kmg/console" 9 "github.com/bronze1man/kmg/encoding/kmgYaml" 10 "github.com/bronze1man/kmg/kmgReflect" 11 ) 12 13 type ParpareReflect struct { 14 } 15 16 func (command *ParpareReflect) GetNameConfig() *console.NameConfig { 17 return &console.NameConfig{Name: "ParpareReflect", Short: `parse source code to parpare some data for kmgReflect`} 18 } 19 func (command *ParpareReflect) Execute(context *console.Context) error { 20 //parse all file in GOPATH 21 wd, err := os.Getwd() 22 if err != nil { 23 return err 24 } 25 root := filepath.Join(wd, "src") 26 contextDecl, err := kmgReflect.NewContextDeclFromSrcPath(root) 27 if err != nil { 28 return err 29 } 30 out, err := kmgYaml.Marshal(contextDecl) 31 if err != nil { 32 return err 33 } 34 35 _, err = context.Stdout.Write(out) 36 if err != nil { 37 return err 38 } 39 return nil 40 } 41 */