function Util.MakeListableType(o,T)local u={Listable=true,Transform=o.Transform,Validate=o.Validate,ValidateOnce=o.ValidateOnce,Autocomplete=o.Autocomplete,Default=o.Default;Parse=function(...)return{o.Parse(...)}end}if T then for o,T in pairs(T)do u[o]=T end end return u end local function o(o)return o: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 T(o)return o: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(o,T)T=Util.ParseEscapeSequences(T)T=Util.EncodeEscapedOperators(T)local u=T:split("\038\038")local z=""for T,W in ipairs(u)do local S=z:gsub("\037\036","\092\120\050\052")W=W:gsub("\124\124",z:find("\037\115")and("\037\113"):format(S)or S)z=tostring(o:EvaluateAndRun(Util.RunEmbeddedCommands(o,W)))if T==#u then return z end end end
--- Creates a listable type from a singlular type
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")
		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
