From ded6a5c6e303dc338e4b3922470acd3d222e9e57 Mon Sep 17 00:00:00 2001 From: Zorglube Date: Fri, 8 Jul 2022 14:20:26 +0200 Subject: [PATCH] Manage Env Var to provide parameters --- main.go | 16 ++++++++-------- readme.md | 35 ++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/main.go b/main.go index 5f13167..cebec56 100644 --- a/main.go +++ b/main.go @@ -54,14 +54,14 @@ func setupSettings(adminPass string, confFile string) error { } type args struct { - Addr string `arg:"-l,--addr" help:"host:port of the HTTP server"` - RtmpAddr string `arg:"-r,--rtmp" help:"host:port of the RTMP server"` - StreamKey string `arg:"-k,--key" help:"Stream key, to protect your stream"` - AdminPass string `arg:"-a,--admin" help:"Set admin password. Overrides configuration in settings.json. This will not write the password to settings.json."` - ConfigFile string `arg:"-f,--config" help:"URI of the conf file"` - StaticDir string `arg:"-s,--static" help:"Directory to read static files from by default"` - EmotesDir string `arg:"-e,--emotes" help:"Directory to read emotes. By default it uses the executable directory"` - WriteStatic bool `arg:"--write-static" help:"write static files to the static dir"` + Addr string `arg:"-l,--addr,env:MN_ADDR" help:"host:port of the HTTP server"` + RtmpAddr string `arg:"-r,--rtmp,env:MN_RTMP" help:"host:port of the RTMP server"` + StreamKey string `arg:"-k,--key,env:MN_STREAM_KEY" help:"Stream key, to protect your stream"` + AdminPass string `arg:"-a,--admin,env:MN_ADMIN_PASS" help:"Set admin password. Overrides configuration in settings.json. This will not write the password to settings.json."` + ConfigFile string `arg:"-f,--config,env:MN_CONFIG" help:"URI of the conf file"` + StaticDir string `arg:"-s,--static,env:MN_STATIC" help:"Directory to read static files from by default"` + EmotesDir string `arg:"-e,--emotes,env:MN_EMOTES" help:"Directory to read emotes. By default it uses the executable directory"` + WriteStatic bool `arg:"--write-static,env:MN_WRITE_STATIC" help:"write static files to the static dir"` } func main() { diff --git a/readme.md b/readme.md index 0a75db6..79e7e6e 100644 --- a/readme.md +++ b/readme.md @@ -124,21 +124,30 @@ and a chat only version at http://your.domain.host:8089/chat ``` -The default listen port is `:8089`. It can be changed by providing a new port -at startup: +Some configurations values can be provided by three ways environment variables, run args, settings.json file. ```text -Usage of .\MovieNight.exe: - -e bool - Whether or not to download approved emotes on startup (default "false") - -k string - Stream key, to protect your stream (default: "") - -l string - host:port of the MovieNight (default ":8089") - -r string - host:port of the RTMP server (default ":1935") - -f string - the settings file you want to use (default "./settings.json") +Usage: MovieNight.exe [--addr ADDR] [--rtmp RTMP] [--key KEY] [--admin ADMIN] [--config CONFIG] [--static STATIC] [--emotes EMOTES] [--write-static] + +Options: + --addr ADDR, -l ADDR + host:port of the HTTP server [env: MN_ADDR] + --rtmp RTMP, -r RTMP + host:port of the RTMP server [env: MN_RTMP] + --key KEY, -k KEY + Stream key, to protect your stream [env: MN_STREAM_KEY] + --admin ADMIN, -a ADMIN + Set admin password. Overrides configuration in settings.json. This will not write the password to settings.json. [env: MN_ADMIN_PASS] + --config CONFIG, -f CONFIG + URI of the conf file [env: MN_CONFIG] + --static STATIC, -s STATIC + Directory to read static files from by default [env: MN_STATIC] + --emotes EMOTES, -e EMOTES + Directory to read emotes. By default it uses the executable directory [env: MN_EMOTES] + --write-static + write static files to the static dir + --help, -h + display this help and exit ``` ## Configuration