diff options
-rw-r--r-- | locale/en-us/script.lua | 6 | ||||
-rw-r--r-- | locale/zh-cn/script.lua | 6 | ||||
-rw-r--r-- | script/cli/check.lua | 19 |
3 files changed, 26 insertions, 5 deletions
diff --git a/locale/en-us/script.lua b/locale/en-us/script.lua index 9d8cf34e..5e9a4099 100644 --- a/locale/en-us/script.lua +++ b/locale/en-us/script.lua @@ -512,6 +512,12 @@ PLUGIN_TRUST_NO = Don't load this plugin ]] +CLI_CHECK_ERROR_TYPE = +'The argument of CHECK must be a string, but got {}' +CLI_CHECK_ERROR_URI = +'The argument of CHECK must be a valid uri, but got {}' +CLI_CHECK_ERROR_LEVEL = +'Checklevel must be one of: {}' CLI_CHECK_INITING = 'Initializing ...' CLI_CHECK_SUCCESS = diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua index c3b1d33f..32cd7d13 100644 --- a/locale/zh-cn/script.lua +++ b/locale/zh-cn/script.lua @@ -511,6 +511,12 @@ PLUGIN_TRUST_NO = 不要加载此插件 ]] +CLI_CHECK_ERROR_TYPE = +'check 必须是一个字符串,但是是一个 {}' +CLI_CHECK_ERROR_URI = +'check 必须是一个有效的 URI,但是是 {}' +CLI_CHECK_ERROR_LEVEL = +'checklevel 必须是这些值之一:{}' CLI_CHECK_INITING = '正在初始化...' CLI_CHECK_SUCCESS = diff --git a/script/cli/check.lua b/script/cli/check.lua index 670b10f4..dd2e7737 100644 --- a/script/cli/check.lua +++ b/script/cli/check.lua @@ -8,17 +8,27 @@ local json = require 'json-beautify' local lang = require 'language' local define = require 'proto.define' local config = require 'config.config' -local timer = require 'timer' -local platform = require 'bee.platform' + +lang(LOCALE) if type(CHECK) ~= 'string' then - print(('The argument of CHECK must be a string, but got %s'):format(type(CHECK))) + print(lang.script('CLI_CHECK_ERROR_TYPE', type(CHECK))) + return end local rootUri = furi.encode(CHECK) if not rootUri then - print(('The argument of CHECK must be a valid uri, but got %s'):format(CHECK)) + print(lang.script('CLI_CHECK_ERROR_URI', CHECK)) + return +end + +if CHECKLEVEL then + if not define.DiagnosticSeverity[CHECKLEVEL] then + print(lang.script('CLI_CHECK_ERROR_LEVEL', 'Error, Warning, Information, Hint')) + return + end end +local checkLevel = define.DiagnosticSeverity[CHECKLEVEL] or define.DiagnosticSeverity.Warning util.enableCloseFunction() @@ -40,7 +50,6 @@ lclient():start(function (client) ws.awaitReady(rootUri) - local checkLevel = define.DiagnosticSeverity[CHECKLEVEL] or define.DiagnosticSeverity.Warning local disables = config.get(rootUri, 'Lua.diagnostics.disable') for name, serverity in pairs(define.DiagnosticDefaultSeverity) do serverity = config.get(rootUri, 'Lua.diagnostics.severity')[name] or 'Warning' |