File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ public protocol CommandProtocol {
2020 /// `help`).
2121 var verb : String { get }
2222
23+ /// Optional list of additional verbs which can be used to invoke this command.
24+ var aliases : [ String ] { get }
25+
2326 /// A human-readable, high-level description of what this command is used
2427 /// for.
2528 var function : String { get }
@@ -96,6 +99,10 @@ public final class CommandRegistry<ClientError: Error> {
9699 {
97100 for command in commands {
98101 commandsByVerb [ command. verb] = CommandWrapper ( command)
102+ // Register command for each additional alias
103+ for alias in command. aliases {
104+ commandsByVerb [ alias] = CommandWrapper ( command)
105+ }
99106 }
100107 return self
101108 }
Original file line number Diff line number Diff line change @@ -18,9 +18,11 @@ import Foundation
1818/// let helpCommand = HelpCommand(registry: commands)
1919/// commands.register(helpCommand)
2020public struct HelpCommand < ClientError: Error > : CommandProtocol {
21+
2122 public typealias Options = HelpOptions < ClientError >
2223
2324 public let verb = " help "
25+ public let aliases : [ String ] = [ ]
2426 public let function : String
2527
2628 private let registry : CommandRegistry < ClientError >
You can’t perform that action at this time.
0 commit comments