45 lines
1.0 KiB
Lua
45 lines
1.0 KiB
Lua
local M = {}
|
|
|
|
CmdsList = nil
|
|
|
|
function M.checkCommand(cmd, desc)
|
|
local toRun = ""
|
|
|
|
if IS_UNIX then
|
|
toRun = "command -v " .. cmd
|
|
else
|
|
toRun = "where " .. cmd
|
|
end
|
|
|
|
local p = io.popen(toRun)
|
|
local output = p:read("*l")
|
|
p:close()
|
|
|
|
if output == nil and desc ~= nil and desc ~= "" then
|
|
vim.api.nvim_echo({ { " ✗ " .. cmd .. " [" .. desc .. "] - not found!", "DiagnosticError" } }, true, {})
|
|
elseif output == nil then
|
|
vim.api.nvim_echo({ { " ✗ " .. cmd .. " not found!", "DiagnosticError" } }, true, {})
|
|
else
|
|
vim.api.nvim_echo({ { " ✓ " .. cmd, "DiagnosticOk" } }, true, {})
|
|
end
|
|
end
|
|
|
|
function M.run()
|
|
if CmdsList == nil or next(CmdsList) == nil then
|
|
vim.api.nvim_echo({ { "Dependencies list passed is null or empty, nothing to check", "DiagnosticWarn" } }, true, {})
|
|
return
|
|
end
|
|
|
|
print("Check installed system commands:")
|
|
for _, cmd in ipairs(CmdsList) do
|
|
M.checkCommand(cmd.cmd, cmd.desc)
|
|
end
|
|
end
|
|
|
|
function M.setup(cmds)
|
|
IS_UNIX = package.config:sub(1, 1) ~= "\\"
|
|
CmdsList = cmds
|
|
end
|
|
|
|
return M
|