function Argument.new(U,C,y)local L={Command=U;Type=nil;Name=C.Name,Object=C,Required=C.Default==nil and C.Optional~=true,Executor=U.Executor;RawValue=y;RawSegments={};TransformedValues={};Prefix="";TextSegmentInProgress="",RawSegmentsAreAutocomplete=false}if type(C.Type)=="\116\097\098\108\101"then L.Type=C.Type else local v,e,P=Util.ParsePrefixedUnionType(U.Cmdr.Registry:GetTypeName(C.Type),y)L.Type=U.Dispatcher.Registry:GetType(v)L.RawValue=e L.Prefix=P if L.Type==nil then error(string.format("\037\115 \104\097\115 \097\110 \117\110\114\101\103\105\115\116\101\114\101\100 \116\121\112\101 \037\113",L.Name or"\060\110\111\110\101\062",v or"\060\110\111\110\101\062"))end end setmetatable(L,Argument)L:Transform()return L end function Argument.GetDefaultAutocomplete(U)if U.Type.Autocomplete then local C=U:TransformSegment("")local y,L=U.Type.Autocomplete(C)return y,L or{}end return{}end
--- Returns a new ArgumentContext, an object that handles parsing and validating arguments
function Argument.new(command, argumentObject, value)
	local self = {
		Command = command, -- The command that owns this argument
		Type = nil, -- The type definition
		Name = argumentObject.Name, -- The name for this specific argument
		Object = argumentObject, -- The raw ArgumentObject (definition)
		Required = argumentObject.Default == nil and argumentObject.Optional ~= true, -- If the argument is required or not.
		Executor = command.Executor, -- The player who is running the command
		RawValue = value, -- The raw, unparsed value
		RawSegments = {}, -- The raw, unparsed segments (if the raw value was comma-sep)
		TransformedValues = {}, -- The transformed value (generated later)
		Prefix = "", -- The prefix for this command (%Team)
		TextSegmentInProgress = "", -- The text of the raw segment the user is currently typing.
		RawSegmentsAreAutocomplete = false,
	}

	if type(argumentObject.Type) == "table" then
		self.Type = argumentObject.Type
	else
		local parsedType, parsedRawValue, prefix =
			Util.ParsePrefixedUnionType(command.Cmdr.Registry:GetTypeName(argumentObject.Type), value)

		self.Type = command.Dispatcher.Registry:GetType(parsedType)
		self.RawValue = parsedRawValue
		self.Prefix = prefix

		if self.Type == nil then
			error(string.format("%s has an unregistered type %q", self.Name or "<none>", parsedType or "<none>"))
		end
	end

	setmetatable(self, Argument)

	self:Transform()

	return self
end

function Argument:GetDefaultAutocomplete()
	if self.Type.Autocomplete then
		local transformedEmpty = self:TransformSegment("")
		local strings, options = self.Type.Autocomplete(transformedEmpty)

		return strings, options or {}
	end

	return {}
end
