diff --git a/Sources/Commandant/Command.swift b/Sources/Commandant/Command.swift index db5b9ba..438289b 100644 --- a/Sources/Commandant/Command.swift +++ b/Sources/Commandant/Command.swift @@ -20,6 +20,9 @@ public protocol CommandProtocol { /// `help`). var verb: String { get } + /// Optional list of additional verbs which can be used to invoke this command. + var aliases: [String] { get } + /// A human-readable, high-level description of what this command is used /// for. var function: String { get } @@ -96,6 +99,10 @@ public final class CommandRegistry { { for command in commands { commandsByVerb[command.verb] = CommandWrapper(command) + // Register command for each additional alias + for alias in command.aliases { + commandsByVerb[alias] = CommandWrapper(command) + } } return self } diff --git a/Sources/Commandant/HelpCommand.swift b/Sources/Commandant/HelpCommand.swift index 0fd3bbf..917f75f 100644 --- a/Sources/Commandant/HelpCommand.swift +++ b/Sources/Commandant/HelpCommand.swift @@ -18,9 +18,11 @@ import Foundation /// let helpCommand = HelpCommand(registry: commands) /// commands.register(helpCommand) public struct HelpCommand: CommandProtocol { + public typealias Options = HelpOptions public let verb = "help" + public let aliases: [String] = [] public let function: String private let registry: CommandRegistry