bee run auto download swagger & auto doc ten

This commit is contained in:
astaxie 2014-06-23 23:02:46 +08:00
parent 6181668e0a
commit 82581a7c30
1 changed files with 15 additions and 2 deletions

17
run.go
View File

@ -23,7 +23,7 @@ import (
) )
var cmdRun = &Command{ var cmdRun = &Command{
UsageLine: "run [appname] [watchall] [-main=*.go]", UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-docgen=true]",
Short: "run the app which can hot compile", Short: "run the app which can hot compile",
Long: ` Long: `
start the appname throw exec.Command start the appname throw exec.Command
@ -46,9 +46,14 @@ when the file has changed bee will auto go build and restart the app
var mainFiles ListOpts var mainFiles ListOpts
var downdoc docValue
var docgen docValue
func init() { func init() {
cmdRun.Run = runApp cmdRun.Run = runApp
cmdRun.Flag.Var(&mainFiles, "main", "specify main go files") cmdRun.Flag.Var(&mainFiles, "main", "specify main go files")
cmdRun.Flag.Var(&docgen, "docgen", "auto generate the docs")
cmdRun.Flag.Var(&downdoc, "downdoc", "auto download swagger file when not exist")
} }
var appname string var appname string
@ -93,13 +98,21 @@ func runApp(cmd *Command, args []string) {
} }
} }
if len(args) >= 2 && args[1] == "true" { if docgen == "true" {
NewWatcher(paths, files, true) NewWatcher(paths, files, true)
Autobuild(files, true) Autobuild(files, true)
} else { } else {
NewWatcher(paths, files, false) NewWatcher(paths, files, false)
Autobuild(files, false) Autobuild(files, false)
} }
if downdoc == "true" {
if _, err := os.Stat(path.Join(crupath, "swagger")); err != nil {
if os.IsNotExist(err) {
downloadFromUrl(swaggerlink, "swagger.zip")
err := unzipAndDelete("swagger.zip", "swagger")
}
}
}
for { for {
select { select {
case <-exit: case <-exit: