summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorcarsakiller <carsakiller@gmail.com>2024-05-10 03:14:14 +0000
committercarsakiller <carsakiller@gmail.com>2024-05-10 03:14:14 +0000
commit4c7530e997449d5d01ca758f2bea8223e36aafc7 (patch)
treebc82bdc2fd89035dfb5e5d8868162fe96f069dd8 /script
parent3ead0aac05e5305fbfb8a0c1bfd7dd838a2eb793 (diff)
downloadlua-language-server-4c7530e997449d5d01ca758f2bea8223e36aafc7.zip
add: load ENV variables as args
Diffstat (limited to 'script')
-rw-r--r--script/config/env.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/script/config/env.lua b/script/config/env.lua
new file mode 100644
index 00000000..163ee404
--- /dev/null
+++ b/script/config/env.lua
@@ -0,0 +1,55 @@
+-- Handles loading environment arguments
+
+---ENV args are defined here.
+---- `name` is the ENV arg name
+---- `key` is the value used to index `_G` for setting the argument
+---@type { name: string, key: string }[]
+local vars = {
+ {
+ name = "LLS_CHECK_LEVEL",
+ key = "CHECKLEVEL",
+ },
+ {
+ name = "LLS_CHECK_PATH",
+ key = "CHECK",
+ },
+ {
+ name = "LLS_CONFIG_PATH",
+ key = "CONFIGPATH"
+ },
+ {
+ name = "LLS_DOC_OUT_PATH",
+ key = "DOC_OUT_PATH",
+ },
+ {
+ name = "LLS_DOC_PATH",
+ key = "DOC",
+ },
+ {
+ name = "LLS_FORCE_ACCEPT_WORKSPACE",
+ key = "FORCE_ACCEPT_WORKSPACE"
+ },
+ {
+ name = "LLS_LOCALE",
+ key = "LOCALE",
+ },
+ {
+ name = "LLS_LOG_LEVEL",
+ key = "LOGLEVEL",
+ },
+ {
+ name = "LLS_LOG_PATH",
+ key = "LOGPATH",
+ },
+ {
+ name = "LLS_META_PATH",
+ key = "METAPATH"
+ }
+}
+
+for _, var in ipairs(vars) do
+ local value = os.getenv(var.name)
+ if value then
+ _G[var.key] = value
+ end
+end