function Util.MakeListableType(m,E)local M={Listable=true;Transform=m.Transform,Validate=m.Validate,Autocomplete=m.Autocomplete;Default=m.Default;Parse=function(...)return{m.Parse(...)}end}if E then for m,E in pairs(E)do M[m]=E end end return M end local function m(m)return m: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 E(m)return m: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(m,E)E=Util.ParseEscapeSequences(E)E=Util.EncodeEscapedOperators(E)local M=E:split("\038\038")local Q=""for E,J in ipairs(M)do local L=Q:gsub("\037\036","\092\120\050\052")J=J:gsub("\124\124",Q:find("\037\115")and("\037\113"):format(L)or L)Q=tostring(m:EvaluateAndRun(Util.RunEmbeddedCommands(m,J)))if E==#M then return Q 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,
		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
