From a655f78a4eed61e136f7366340c2a9f783f7b2f5 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 11 Sep 2013 18:35:24 -0400 Subject: [PATCH] Added auto-detect appname --- bee.json | 1 + run.go | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bee.json b/bee.json index 4665137..4d39b6a 100644 --- a/bee.json +++ b/bee.json @@ -1,4 +1,5 @@ { + "watch_imports": true, "go_install": false, "watch_ext": [], "dir_structure":{ diff --git a/run.go b/run.go index edc1f33..b1ed41e 100644 --- a/run.go +++ b/run.go @@ -66,6 +66,8 @@ func init() { var appname string var conf struct { + // Indicates whether to watch imports changes. + WatchImports bool `json:"watch_imports"` // Indicates whether execute "go install" before "go build". GoInstall bool `json:"go_install"` WatchExt []string `json:"watch_ext"` @@ -84,12 +86,13 @@ var conf struct { func runApp(cmd *Command, args []string) { 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() + 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) err := loadConfig() @@ -106,7 +109,6 @@ func runApp(cmd *Command, args []string) { paths = append(paths, conf.DirStruct.Others...) NewWatcher(paths) - appname = args[0] Autobuild() for { select {