diff --git a/README.md b/README.md index 084f0cf..8a3da77 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ On systems with SELinux you may have to run `restorecon /path/to/puma-dev` in or Simply symlink your app's directory into `~/.puma-dev`! That's it! -You can use the built-in helper subcommand: `puma-dev link [-n name] [dir]` to link app directories into your puma-dev directory (`~/.puma-dev` by default). +You can use the built-in helper subcommand: `puma-dev link [-n name] [dir]` to link app directories into your puma-dev directory (`~/.puma-dev` by default, but can be changed with `PUMA_DEV_APP_DIR`). ### Options @@ -352,4 +352,3 @@ To build puma-dev, follow these steps: Tagged builds (e.g `v0.18.0`) will automatically create [pre-release](https://github.com/puma/puma-dev/releases) with artifacts for use in the Homebrew formula. All [builds with passing tests](https://github.com/puma/puma-dev/actions) will publish binaries that are saved for 90 days. - diff --git a/cmd/puma-dev/main_darwin.go b/cmd/puma-dev/main_darwin.go index 11fdbdb..0ad471e 100644 --- a/cmd/puma-dev/main_darwin.go +++ b/cmd/puma-dev/main_darwin.go @@ -21,7 +21,7 @@ var ( fDNSPort = flag.Int("dns-port", 9253, "port to listen on dns for") fHTTPPort = flag.Int("http-port", 9280, "port to listen on http for") fTLSPort = flag.Int("https-port", 9283, "port to listen on https for") - fDir = flag.String("dir", "~/.puma-dev", "directory to watch for apps") + fDir = flag.String("dir", dev.GetEnv("PUMA_DEV_APP_DIR", "~/.puma-dev"), "directory to watch for apps") fTimeout = flag.Duration("timeout", 15*60*time.Second, "how long to let an app idle for") fPow = flag.Bool("pow", false, "Mimic pow's settings") fLaunch = flag.Bool("launchd", false, "Use socket from launchd") diff --git a/cmd/puma-dev/main_linux.go b/cmd/puma-dev/main_linux.go index b0e4a9f..ac3f975 100644 --- a/cmd/puma-dev/main_linux.go +++ b/cmd/puma-dev/main_linux.go @@ -17,7 +17,7 @@ import ( var ( fDebug = flag.Bool("debug", false, "enable debug output") - fDir = flag.String("dir", "~/.puma-dev", "directory to watch for apps") + fDir = flag.String("dir", dev.GetEnv("PUMA_DEV_APP_DIR", "~/.puma-dev"), "directory to watch for apps") fDomains = flag.String("d", "test", "domains to handle, separate with :, defaults to test") fHTTPPort = flag.Int("http-port", 9280, "port to listen on http for") fNoServePublicPaths = flag.String("no-serve-public-paths", "", "Disable static file server for specific paths under /public") diff --git a/dev/get_env.go b/dev/get_env.go new file mode 100644 index 0000000..765928b --- /dev/null +++ b/dev/get_env.go @@ -0,0 +1,8 @@ +package dev + +func GetEnv(key, fallback string) string { + if value, ok := os.LookupEnv(key); ok { + return value + } + return fallback +}