From 1055a8547668308633601a8b67f1a0b52075de3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 11 Aug 2023 19:04:34 +0800 Subject: commandline parameter `--force-accept-workspace` resolve #2159 --- changelog.md | 1 + main.lua | 2 +- script/global.d.lua | 3 +++ script/workspace/workspace.lua | 6 ++++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index a39f505d..bbfd1250 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## 3.7.0 * `NEW` support `---@type` and `--[[@as]]` for return statement +* `NEW` commandline parameter `--force-accept-workspace`: allowing the use of the root directory or home directory as the workspace * `FIX` wrong hover and signature for method with varargs and overloads * `FIX` [#2155] * `FIX` [#2224] diff --git a/main.lua b/main.lua index cbf27129..8ecfd472 100644 --- a/main.lua +++ b/main.lua @@ -36,7 +36,7 @@ local function loadArgs() end end if key then - _G[key:upper()] = getValue(value) + _G[key:upper():gsub('-', '_')] = getValue(value) end end end diff --git a/script/global.d.lua b/script/global.d.lua index f84ff0e4..aedcc38c 100644 --- a/script/global.d.lua +++ b/script/global.d.lua @@ -77,3 +77,6 @@ jit = false -- connect to client by socket ---@type integer SOCKET = 0 + +-- Allowing the use of the root directory or home directory as the workspace +FORCE_ACCEPT_WORKSPACE = false diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index da2f9daf..97518e84 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -50,8 +50,10 @@ function m.create(uri) m.folders[#m.folders+1] = scp if uri == furi.encode '/' or uri == furi.encode(os.getenv 'HOME' or '') then - client.showMessage('Error', lang.script('WORKSPACE_NOT_ALLOWED', furi.decode(uri))) - scp:set('bad root', true) + if not FORCE_ACCEPT_WORKSPACE then + client.showMessage('Error', lang.script('WORKSPACE_NOT_ALLOWED', furi.decode(uri))) + scp:set('bad root', true) + end end end -- cgit v1.2.3