blob: c0d756e30946f238b7a91b6a55f0dde1a89775ce [file] [edit]
protocol Subcommand {
static var helpText: String { get }
static func parse(_ args: ArraySlice<String>) throws(ArgumentParseError) -> Self
func run()
}
extension Subcommand {
static func run(_ args: ArraySlice<String>) {
do {
try parse(args).run()
} catch {
switch error {
case .failure(let message):
print(message)
case .unexpectedArgument(let arg):
print("Unexpected argument: \(arg)")
}
print(helpText)
}
}
}