-- Compiled with roblox-ts v3.0.0 local TS = _G[script] local _store = TS.import(script, script.Parent.Parent.Parent.Parent, "store") local commandArgIndex = _store.commandArgIndex local currentCommandPath = _store.currentCommandPath local currentTextPart = _store.currentTextPart local terminalArgIndex = _store.terminalArgIndex local _command = TS.import(script, script.Parent.Parent, "command") local formatPartsAsPath = _command.formatPartsAsPath local getArgumentNames = _command.getArgumentNames local function replaceTextPart(text, ...) local suggestions = { ... } local currentPart = currentTextPart() local _result = currentPart if _result ~= nil then _result = #_result end local _condition = _result if _condition == nil then _condition = 0 end local currentPartSize = _condition local _text = text local _arg1 = #text - currentPartSize local result = string.sub(_text, 0, _arg1) result ..= table.concat(suggestions, " ") return result end local function completeCommand(registry, text, textParts, suggestion) local atNextPart = string.sub(text, -1) == " " local _array = {} local _length = #_array table.move(textParts, 1, #textParts, _length + 1, _array) local pathParts = _array if not atNextPart then local _arg0 = #textParts - 1 table.remove(pathParts, _arg0 + 1) end local _suggestion = suggestion table.insert(pathParts, _suggestion) local _command_1 = registry:getCommandByString(formatPartsAsPath(pathParts)) if _command_1 ~= nil then _command_1 = _command_1.options end local command = _command_1 local result = replaceTextPart(text, suggestion) -- Add a space if this path isn't a command (meaning it's a group) or is a command with arguments local _condition = command == nil if not _condition then local _result = command.arguments if _result ~= nil then _result = #_result == 0 end local _condition_1 = _result if _condition_1 == nil then _condition_1 = true end _condition = not _condition_1 end if _condition then result ..= " " end return result end local function completeArgument(text, suggestion, commandArgCount) local argIndex = terminalArgIndex() if argIndex == nil or commandArgCount == 0 then return text end local result = replaceTextPart(text, suggestion) if argIndex < commandArgCount - 1 then result ..= " " end return result end local function getSuggestedText(registry, text, textParts, atNextPart, suggestion) if suggestion == nil then return "" end local suggestionText if #textParts == 0 or suggestion.type == "command" then suggestionText = suggestion.title else local command = currentCommandPath() local argIndex = terminalArgIndex() if command == nil or argIndex == nil then return "" end if atNextPart and argIndex == commandArgIndex() then suggestionText = suggestion.title elseif not (#suggestion.others == 0) then suggestionText = suggestion.others[1] else local _condition = currentTextPart() if _condition == nil then _condition = "" end suggestionText = _condition end local argNames = getArgumentNames(registry, command) for i = argIndex + 1, #argNames - 1 do suggestionText ..= ` {argNames[i + 1]}` end end local _result = currentTextPart() if _result ~= nil then _result = #_result end local _condition = _result if _condition == nil then _condition = 0 end local partSize = _condition local result = text local _suggestionText = suggestionText local _arg0 = partSize + 1 result ..= string.sub(_suggestionText, _arg0) return result end return { completeCommand = completeCommand, completeArgument = completeArgument, getSuggestedText = getSuggestedText, }