1
0
mirror of https://github.com/beego/bee.git synced 2025-07-05 18:20:18 +00:00

bee support generate docs from the source code

This commit is contained in:
astaxie
2014-06-18 12:19:03 +08:00
parent 7140e9be38
commit fdade4356e
3 changed files with 439 additions and 1 deletions

45
g.go Normal file
View File

@ -0,0 +1,45 @@
package main
import "os"
var cmdGenerate = &Command{
UsageLine: "generate [Command]",
Short: "generate code based on application",
Long: `
bee g model [modelfile] [dbconfig]
generate model base on struct
bee g controller [modelfile]
generate RESTFul controllers based on modelfile
bee g router [controllerfile]
generate router based on controllerfile
bee g docs
generate swagger doc file
bee g test [routerfile]
generate testcase
`,
}
func generateCode(cmd *Command, args []string) {
curpath, _ := os.Getwd()
if len(args) < 1 {
ColorLog("[ERRO] command is missing\n")
os.Exit(2)
}
gopath := os.Getenv("GOPATH")
Debugf("gopath:%s", gopath)
if gopath == "" {
ColorLog("[ERRO] $GOPATH not found\n")
ColorLog("[HINT] Set $GOPATH in your environment vairables\n")
os.Exit(2)
}
gcmd := args[0]
switch gcmd {
case "docs":
generateDocs(curpath)
default:
ColorLog("[ERRO] command is missing\n")
}
ColorLog("[SUCC] generate successfully created!\n")
}