CommandArgumentConvertible
public protocol CommandArgumentConvertible
Marks a type as CommandArgumentConvertible.
These types can be created from one or more arguments passed into a command.
-
The type arguments will be resolved to.
Defaults to
SelfDeclaration
Swift
associatedtype ResolvedArgument = Self -
typedNameDefault implementationName used in descriptions.
Int.typedName // "Int"Default Implementation
Declaration
Swift
static var typedName: String { get } -
Attempts to resolve an argument from the provided string.
Throws
CommandError.UnableToConvertArgumentwhenResolvedArgumentcan not be created fromargumentCommandError.ArgumentNotFoundwhen no argument is foundDeclaration
Swift
static func resolveArgument(_ argument: String, on event: CommandEvent) throws -> ResolvedArgumentParameters
argumentString taken from the message body.
eventThe
CommandEventthis argument should be resolved for.Return Value
The resolved argument
-
resolveArgument(_:Default implementationarg: on: ) Attempts to resolve an argument from the provided string.
A default implementation is provided. The default implementation will throw
CommandArgument.ArgumentNotFoundwhennilis passed in.Throws
CommandError.UnableToConvertArgumentwhenResolvedArgumentcan not be created fromargumentCommandError.ArgumentNotFoundwhen no argument is foundDefault Implementation
Declaration
Swift
static func resolveArgument(_ argument: String?, arg: CommandArgument, on event: CommandEvent) throws -> ResolvedArgumentParameters
argumentString taken from the message body.
eventThe
CommandEventthis argument should be resolved for.Return Value
The resolved argument
View on GitHub
CommandArgumentConvertible Protocol Reference