Added auto-detect appname

This commit is contained in:
Unknown 2013-09-11 18:35:24 -04:00
parent 0f88e47773
commit a655f78a4e
2 changed files with 9 additions and 6 deletions

View File

@ -1,4 +1,5 @@
{ {
"watch_imports": true,
"go_install": false, "go_install": false,
"watch_ext": [], "watch_ext": [],
"dir_structure":{ "dir_structure":{

14
run.go
View File

@ -66,6 +66,8 @@ func init() {
var appname string var appname string
var conf struct { var conf struct {
// Indicates whether to watch imports changes.
WatchImports bool `json:"watch_imports"`
// Indicates whether execute "go install" before "go build". // Indicates whether execute "go install" before "go build".
GoInstall bool `json:"go_install"` GoInstall bool `json:"go_install"`
WatchExt []string `json:"watch_ext"` WatchExt []string `json:"watch_ext"`
@ -84,12 +86,13 @@ var conf struct {
func runApp(cmd *Command, args []string) { func runApp(cmd *Command, args []string) {
exit := make(chan bool) exit := make(chan bool)
if len(args) != 1 {
com.ColorLog("[ERRO] Cannot start running[ %s ]\n",
"argument 'appname' is missing")
os.Exit(2)
}
crupath, _ := os.Getwd() crupath, _ := os.Getwd()
if len(args) != 1 {
appname = path.Base(crupath)
com.ColorLog("[INFO] Uses '%s' as 'appname'\n", appname)
} else {
appname = args[0]
}
Debugf("current path:%s\n", crupath) Debugf("current path:%s\n", crupath)
err := loadConfig() err := loadConfig()
@ -106,7 +109,6 @@ func runApp(cmd *Command, args []string) {
paths = append(paths, conf.DirStruct.Others...) paths = append(paths, conf.DirStruct.Others...)
NewWatcher(paths) NewWatcher(paths)
appname = args[0]
Autobuild() Autobuild()
for { for {
select { select {