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
Self
Declaration
Swift
associatedtype ResolvedArgument = Self
-
typedName
Default 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.UnableToConvertArgument
whenResolvedArgument
can not be created fromargument
CommandError.ArgumentNotFound
when no argument is foundDeclaration
Swift
static func resolveArgument(_ argument: String, on event: CommandEvent) throws -> ResolvedArgument
Parameters
argument
String taken from the message body.
event
The
CommandEvent
this 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.ArgumentNotFound
whennil
is passed in.Throws
CommandError.UnableToConvertArgument
whenResolvedArgument
can not be created fromargument
CommandError.ArgumentNotFound
when no argument is foundDefault Implementation
Declaration
Swift
static func resolveArgument(_ argument: String?, arg: CommandArgument, on event: CommandEvent) throws -> ResolvedArgument
Parameters
argument
String taken from the message body.
event
The
CommandEvent
this argument should be resolved for.Return Value
The resolved argument