all repos — honk @ ab3ab230dc142568729f87da1357753957973e2d

my fork of honk

allow datadir and viewdir to be set via env.  from klimpong
Ted Unangst tedu@tedunangst.com
Mon, 11 Mar 2024 22:21:12 -0400
commit

ab3ab230dc142568729f87da1357753957973e2d

parent

5a281f2cfd927c079e72026bd4ed1d5ed2e43293

3 files changed, 13 insertions(+), 2 deletions(-)

jump to
M docs/honk.8docs/honk.8

@@ -62,11 +62,15 @@ The root data directory, where the database and other user data are stored.

This directory contains all user data that persists across upgrades. Requires write access. Defaults to ".". +Also set by +.Ev HONK_DATADIR . .It Fl viewdir Ar dir The root view directory, where html and other templates are stored. The contents of this directory are generally replaced with each release. Read only. Defaults to ".". +Also set by +.Ev HONK_VIEWDIR . .El .Pp The following options control log output.
M main.gomain.go

@@ -103,8 +103,8 @@ callback: func(args []string) {

usage() }, } - flag.StringVar(&dataDir, "datadir", dataDir, "data directory") - flag.StringVar(&viewDir, "viewdir", viewDir, "view directory") + flag.StringVar(&dataDir, "datadir", getenv("HONK_DATADIR", dataDir), "data directory") + flag.StringVar(&viewDir, "viewdir", getenv("HONK_VIEWDIR", viewDir), "view directory") flag.Usage = usage flag.Parse()
M util.goutil.go

@@ -461,3 +461,10 @@ }

listenSocket = listener return listener, nil } + +func getenv(key, def string) string { + if val, ok := os.LookupEnv(key); ok { + return val + } + return def +}