--[[ Various console command helper functions ]] local fuzzel = nrequire("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