2015-07-11 10:30:30 +00:00
|
|
|
//
|
|
|
|
// main.swift
|
|
|
|
// mas-cli
|
|
|
|
//
|
|
|
|
// Created by Andrew Naylor on 11/07/2015.
|
|
|
|
// Copyright © 2015 Andrew Naylor. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2015-09-03 23:38:54 +00:00
|
|
|
public struct StderrOutputStream: OutputStreamType {
|
|
|
|
public mutating func write(string: String) {
|
|
|
|
fputs(string, stderr)
|
|
|
|
}
|
|
|
|
}
|
2015-08-02 20:38:38 +00:00
|
|
|
|
|
|
|
let registry = CommandRegistry<MASError>()
|
|
|
|
let helpCommand = HelpCommand(registry: registry)
|
|
|
|
registry.register(AccountCommand())
|
|
|
|
registry.register(InstallCommand())
|
2015-09-13 22:14:14 +00:00
|
|
|
registry.register(ListCommand())
|
|
|
|
registry.register(OutdatedCommand())
|
2015-08-02 20:38:38 +00:00
|
|
|
registry.register(helpCommand)
|
|
|
|
|
2015-09-03 23:13:47 +00:00
|
|
|
registry.main(defaultVerb: helpCommand.verb) { error in
|
2015-09-03 23:38:54 +00:00
|
|
|
if let sourceError = error.sourceError {
|
|
|
|
var stderr = StderrOutputStream()
|
|
|
|
println(sourceError.localizedDescription, &stderr)
|
|
|
|
}
|
2015-09-03 23:13:47 +00:00
|
|
|
exit(Int32(error.code))
|
|
|
|
}
|
2015-07-11 10:30:30 +00:00
|
|
|
|