2019-11-15 19:51:44 +00:00
|
|
|
local fs = _G.fs
|
|
|
|
|
2019-02-12 01:25:12 +00:00
|
|
|
local function completeMultipleChoice(sText, tOptions, bAddSpaces)
|
2019-06-18 19:19:24 +00:00
|
|
|
local tResults = { }
|
|
|
|
for n = 1,#tOptions do
|
|
|
|
local sOption = tOptions[n]
|
|
|
|
if #sOption + (bAddSpaces and 1 or 0) > #sText and string.sub(sOption, 1, #sText) == sText then
|
|
|
|
local sResult = string.sub(sOption, #sText + 1)
|
|
|
|
if bAddSpaces then
|
|
|
|
table.insert(tResults, sResult .. " ")
|
|
|
|
else
|
|
|
|
table.insert(tResults, sResult)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return tResults
|
2019-02-12 01:25:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
_ENV.shell.setCompletionFunction("sys/apps/package.lua",
|
2019-06-18 19:19:24 +00:00
|
|
|
function(_, index, text)
|
|
|
|
if index == 1 then
|
2019-07-03 14:44:30 +00:00
|
|
|
return completeMultipleChoice(text, { "install ", "update ", "uninstall ", "updateall ", "refresh" })
|
2019-06-18 19:19:24 +00:00
|
|
|
end
|
|
|
|
end)
|
2019-11-15 19:51:44 +00:00
|
|
|
|
|
|
|
_ENV.shell.setCompletionFunction("sys/apps/inspect.lua",
|
|
|
|
function(_, index, text)
|
|
|
|
if index == 1 then
|
|
|
|
local components = { }
|
|
|
|
for _, f in pairs(fs.list('sys/modules/opus/ui/components')) do
|
|
|
|
table.insert(components, (f:gsub("%.lua$", "")))
|
|
|
|
end
|
|
|
|
return completeMultipleChoice(text, components)
|
|
|
|
end
|
|
|
|
end)
|