diff --git a/Commandant/Command.swift b/Commandant/Command.swift index 82979ca..17b2c2f 100644 --- a/Commandant/Command.swift +++ b/Commandant/Command.swift @@ -39,7 +39,7 @@ public struct CommandWrapper { public let usage: () -> CommandantError /// Creates a command that wraps another. - private init(_ command: C) { + private init(_ command: C) { verb = command.verb function = command.function run = { (arguments: ArgumentParser) -> Result<(), CommandantError> in @@ -50,8 +50,9 @@ public struct CommandWrapper { } if let options = options.value { - command.run(options) - return .Success() + return command + .run(options) + .mapError(CommandantError.CommandError) } else { return .Failure(options.error!) } @@ -87,7 +88,7 @@ public final class CommandRegistry { /// /// If another command was already registered with the same `verb`, it will /// be overwritten. - public func register(command: C) { + public func register(command: C) { commandsByVerb[command.verb] = CommandWrapper(command) }