diff options
| author | Shulhan <ms@kilabit.info> | 2023-10-29 12:06:37 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-10-29 12:07:11 +0700 |
| commit | b045acde999b90e1a2e2997328f2e345bc84c3c7 (patch) | |
| tree | 737031447fe8bf4ae462a07af33a36539fc346ed | |
| parent | 28e0dbed4c2786ed8328d23b65cfb33d215d56ac (diff) | |
| download | awwan-b045acde999b90e1a2e2997328f2e345bc84c3c7.tar.xz | |
all: replace environment AWWAN_DEVELOPMENT with flag "-dev"
Using flag "-dev" is more explicit than using environment variable.
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | awwan.go | 9 | ||||
| -rw-r--r-- | cmd/awwan/main.go | 9 | ||||
| -rw-r--r-- | internal/internal.go | 4 |
4 files changed, 9 insertions, 15 deletions
@@ -37,7 +37,7 @@ install: lint-www embed .PHONY: dev dev: - AWWAN_DEVELOPMENT=1 go run ./cmd/awwan serve $(AWWAN_WORKSPACE) + go run ./cmd/awwan -dev serve $(AWWAN_WORKSPACE) #{{{ Task to lint the TypeScript files. @@ -307,13 +307,10 @@ func (aww *Awwan) Play(req *Request) (err error) { } // Serve start the web-user interface that serve awwan actions through HTTP. -func (aww *Awwan) Serve() (err error) { - var ( - logp = `Serve` - envDev = os.Getenv(internal.EnvDevelopment) - ) +func (aww *Awwan) Serve(isDev bool) (err error) { + var logp = `Serve` - if len(envDev) > 0 { + if isDev { go internal.Watch() } diff --git a/cmd/awwan/main.go b/cmd/awwan/main.go index 5626025..b44b242 100644 --- a/cmd/awwan/main.go +++ b/cmd/awwan/main.go @@ -104,9 +104,10 @@ Run the web-user interface using the current directory as workspace, } func main() { - var logp = "awwan" - - log.SetFlags(0) + var ( + logp = `awwan` + isDev = flag.Bool(`dev`, false, `run the "serve" command in development mode`) + ) flag.Parse() @@ -197,7 +198,7 @@ func main() { case awwan.CommandModePlay: err = aww.Play(req) case awwan.CommandModeServe: - err = aww.Serve() + err = aww.Serve(*isDev) } if err != nil { log.Fatalf(`%s: %s`, logp, err) diff --git a/internal/internal.go b/internal/internal.go index 5abf0c5..a560612 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -15,10 +15,6 @@ import ( "github.com/shuLhan/share/lib/mlog" ) -// EnvDevelopment if its set, the "serve" command will run in development -// mode, watching any files changes under _www. -const EnvDevelopment = `AWWAN_DEVELOPMENT` - // MemfsWww The embedded _www for web-user interface. // This variable will initialize by initMemfsWww. var MemfsWww *memfs.MemFS |
