blob: b4e844aba761065148768233dc2a89a87e54aa9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
--[[
Various console command helper functions
]]
local fuzzel = include("fuzzel.lua")
local concmd = {}
function concmd.AutocompleteFunction(...)
local opt = {...}
opt = type(opt[1]) == "table" and opt[1] or opt
return function(cmd,strargs)
--Remove spaces and quotes, since we don't want to match them
strargs = string.gsub(strargs,"[\" ]","")
--Find the options that most closely resemble our command so far
local sorted = fuzzel.fad(strargs,opt)
--Add quotes if needed, and preppend the command to each option
for k,v in pairs(sorted) do
if string.find(v," ") ~= nil then
sorted[k] = "\"" .. v .. "\""
end
sorted[k] = cmd .. " " .. sorted[k]
end
return sorted
end
end
return concmd
|