mirror of
https://github.com/akyaiy/GoSally-mvp.git
synced 2026-01-03 15:12:26 +00:00
um add modernc/sqlite
This commit is contained in:
31
com/List.lua
Normal file
31
com/List.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
-- com/List.lua
|
||||
|
||||
local function isValidCommand(name)
|
||||
return name:match("^[%w]+$") ~= nil
|
||||
end
|
||||
|
||||
local function scanDirectory(basePath, targetPath)
|
||||
local res = {}
|
||||
local fullPath = basePath.."/"..targetPath
|
||||
local handle = io.popen('find "'..fullPath..'" -type f -name "*.lua" 2>/dev/null')
|
||||
|
||||
if handle then
|
||||
for filePath in handle:lines() do
|
||||
local fileName = filePath:match("([^/]+)%.lua$")
|
||||
if fileName and isValidCommand(fileName) then
|
||||
local relPath = filePath:gsub("^"..basePath.."/", ""):gsub(".lua$", ""):gsub("/", ">")
|
||||
table.insert(res, relPath)
|
||||
end
|
||||
end
|
||||
handle:close()
|
||||
end
|
||||
|
||||
return #res > 0 and res or nil
|
||||
end
|
||||
|
||||
local basePath = "com"
|
||||
local layer = In.Params and In.Params.layer and In.Params.layer:gsub(">", "/") or nil
|
||||
|
||||
Out.Result = {
|
||||
answer = layer and scanDirectory(basePath, layer) or scanDirectory(basePath, "")
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
if not In.Params.msg or In.Params.msg == "" then
|
||||
Out.Error = {
|
||||
message = "there must be a msg parameter"
|
||||
}
|
||||
return
|
||||
function validate()
|
||||
if not In.Params.msg or In.Params.msg == "" then
|
||||
Out.Error = {
|
||||
message = "there must be a msg parameter"
|
||||
}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
validate()
|
||||
Out.Result.answer = In.Params.msg
|
||||
@@ -1 +1,7 @@
|
||||
Log.Event("got ping")
|
||||
Log.EventWarn("got ping")
|
||||
Log.EventError("got ping")
|
||||
|
||||
Log.Error("mm")
|
||||
|
||||
Out.Result.answer = "pong"
|
||||
@@ -1,3 +1,4 @@
|
||||
---@diagnostic disable: missing-fields, missing-return
|
||||
---@alias AnyTable table<string, any>
|
||||
|
||||
---@type AnyTable
|
||||
@@ -8,4 +9,16 @@ In = {
|
||||
---@type AnyTable
|
||||
Out = {
|
||||
Result = {},
|
||||
}
|
||||
}
|
||||
|
||||
---@class Log
|
||||
---@field Info fun(msg: string)
|
||||
---@field Debug fun(msg: string)
|
||||
---@field Error fun(msg: string)
|
||||
---@field Warn fun(msg: string)
|
||||
---@field Event fun(msg: string)
|
||||
---@field EventError fun(msg: string)
|
||||
---@field EventWarn fun(msg: string)
|
||||
|
||||
---@type Log
|
||||
Log = {}
|
||||
Reference in New Issue
Block a user