function Util.MakeListableType(k,A)local S={Listable=true;Transform=k.Transform,Validate=k.Validate;ValidateOnce=k.ValidateOnce,Autocomplete=k.Autocomplete;Default=k.Default;Parse=function(...)return{k.Parse(...)}end}if A then for k,A in pairs(A)do S[k]=A end end return S end local function k(k)return k:gsub("\092\037\036","\095\095\095\033\067\077\068\082\095\068\079\076\076\065\082\033\095\095\095")end local function A(k)return k:gsub("\095\095\095\033\067\077\068\082\095\068\079\076\076\065\082\033\095\095\095","\036")end function Util.RunCommandString(k,A)A=Util.ParseEscapeSequences(A)A=Util.EncodeEscapedOperators(A)local S=A:split("\038\038")local X=""for A,c in ipairs(S)do local D=(X:gsub("\037\036","\092\120\050\052")):gsub("\037\037","\037\037\037\037")c=c:gsub("\124\124",X:find("\037\115")and("\037\113"):format(D)or D)X=tostring(k:EvaluateAndRun(Util.RunEmbeddedCommands(k,c)))if A==#S then return X end end end

function Util.MakeListableType(type, override)
	local listableType = {
		Listable = true,
		Transform = type.Transform,
		Validate = type.Validate,
		ValidateOnce = type.ValidateOnce,
		Autocomplete = type.Autocomplete,
		Default = type.Default,
		Parse = function(...)
			return {type.Parse(...)}
		end
	}

	if override then
		for key, value in pairs(override) do
			listableType[key] = value
		end
	end

	return listableType
end

local function encodeCommandEscape(text)
	return (text:gsub("\\%$", "___!CMDR_DOLLAR!___"))
end

local function decodeCommandEscape(text)
	return (text:gsub("___!CMDR_DOLLAR!___", "$"))
end

function Util.RunCommandString(dispatcher, commandString)
	commandString = Util.ParseEscapeSequences(commandString)
	commandString = Util.EncodeEscapedOperators(commandString)

	local commands = commandString:split("&&")

	local output = ""
	for i, command in ipairs(commands) do
		local outputEncoded = output:gsub("%$", "\\x24"):gsub("%%","%%%%")
		command = command:gsub("||", output:find("%s") and ("%q"):format(outputEncoded) or outputEncoded)

		output = tostring(
			dispatcher:EvaluateAndRun(
				(
					Util.RunEmbeddedCommands(dispatcher, command)
				)
			)
		)


		if i == #commands then
			return output
		end
	end
end
