mirror of
https://github.com/beego/bee.git
synced 2024-11-26 06:21:34 +00:00
Merge pull request #121 from lei-cao/master
Issue-119: flags for excluding Godeps.
This commit is contained in:
commit
6c98bdfbbc
22
run.go
22
run.go
@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var cmdRun = &Command{
|
var cmdRun = &Command{
|
||||||
UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true]",
|
UsageLine: "run [appname] [watchall] [-main=*.go] [-downdoc=true] [-gendoc=true] [-e=Godeps -e=folderToExclude]",
|
||||||
Short: "run the app and start a Web server for development",
|
Short: "run the app and start a Web server for development",
|
||||||
Long: `
|
Long: `
|
||||||
Run command will supervise the file system of the beego project using inotify,
|
Run command will supervise the file system of the beego project using inotify,
|
||||||
@ -37,11 +37,15 @@ var mainFiles ListOpts
|
|||||||
var downdoc docValue
|
var downdoc docValue
|
||||||
var gendoc docValue
|
var gendoc docValue
|
||||||
|
|
||||||
|
// The flags list of the paths excluded from watching
|
||||||
|
var excludedPaths strFlags
|
||||||
|
|
||||||
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(&gendoc, "gendoc", "auto generate the docs")
|
cmdRun.Flag.Var(&gendoc, "gendoc", "auto generate the docs")
|
||||||
cmdRun.Flag.Var(&downdoc, "downdoc", "auto download swagger file when not exist")
|
cmdRun.Flag.Var(&downdoc, "downdoc", "auto download swagger file when not exist")
|
||||||
|
cmdRun.Flag.Var(&excludedPaths, "e", "Excluded paths[].")
|
||||||
}
|
}
|
||||||
|
|
||||||
var appname string
|
var appname string
|
||||||
@ -129,6 +133,11 @@ func readAppDirectories(directory string, paths *[]string) {
|
|||||||
if strings.HasSuffix(fileInfo.Name(), "docs") {
|
if strings.HasSuffix(fileInfo.Name(), "docs") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isExcluded(fileInfo) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if fileInfo.IsDir() == true && fileInfo.Name()[0] != '.' {
|
if fileInfo.IsDir() == true && fileInfo.Name()[0] != '.' {
|
||||||
readAppDirectories(directory+"/"+fileInfo.Name(), paths)
|
readAppDirectories(directory+"/"+fileInfo.Name(), paths)
|
||||||
continue
|
continue
|
||||||
@ -146,3 +155,14 @@ func readAppDirectories(directory string, paths *[]string) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a file is excluded
|
||||||
|
func isExcluded(fileInfo os.FileInfo) bool {
|
||||||
|
for _, p := range excludedPaths {
|
||||||
|
if strings.HasSuffix(fileInfo.Name(), p) {
|
||||||
|
ColorLog("[INFO] Excluding from watching [ %s ]\n", fileInfo.Name())
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
12
util.go
12
util.go
@ -247,3 +247,15 @@ func camelString(s string) string {
|
|||||||
}
|
}
|
||||||
return string(data[:len(data)])
|
return string(data[:len(data)])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The string flag list, implemented flag.Value interface
|
||||||
|
type strFlags []string
|
||||||
|
|
||||||
|
func (s *strFlags) String() string {
|
||||||
|
return fmt.Sprintf("%d", *s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *strFlags) Set(value string) error {
|
||||||
|
*s = append(*s, value)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user