mas/mas-cli/main.swift
2015-09-13 23:14:56 +01:00

32 lines
805 B
Swift

//
// main.swift
// mas-cli
//
// Created by Andrew Naylor on 11/07/2015.
// Copyright © 2015 Andrew Naylor. All rights reserved.
//
import Foundation
public struct StderrOutputStream: OutputStreamType {
public mutating func write(string: String) {
fputs(string, stderr)
}
}
let registry = CommandRegistry<MASError>()
let helpCommand = HelpCommand(registry: registry)
registry.register(AccountCommand())
registry.register(InstallCommand())
registry.register(ListCommand())
registry.register(OutdatedCommand())
registry.register(helpCommand)
registry.main(defaultVerb: helpCommand.verb) { error in
if let sourceError = error.sourceError {
var stderr = StderrOutputStream()
println(sourceError.localizedDescription, &stderr)
}
exit(Int32(error.code))
}