2015-08-21 13:02:36 +00:00
|
|
|
//
|
|
|
|
// Install.swift
|
|
|
|
// mas-cli
|
|
|
|
//
|
|
|
|
// Created by Andrew Naylor on 21/08/2015.
|
|
|
|
// Copyright (c) 2015 Andrew Naylor. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
struct InstallCommand: CommandType {
|
2015-12-30 21:20:25 +00:00
|
|
|
typealias Options = InstallOptions
|
2015-08-21 13:02:36 +00:00
|
|
|
let verb = "install"
|
|
|
|
let function = "Install from the Mac App Store"
|
|
|
|
|
2015-12-30 21:20:25 +00:00
|
|
|
func run(options: Options) -> Result<(), MASError> {
|
|
|
|
if let error = download(options.appId) {
|
2015-08-24 18:45:54 +00:00
|
|
|
return .Failure(error)
|
2015-08-21 13:02:36 +00:00
|
|
|
}
|
2015-12-30 21:20:25 +00:00
|
|
|
|
|
|
|
return .Success(())
|
2015-08-21 13:02:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct InstallOptions: OptionsType {
|
|
|
|
let appId: UInt64
|
|
|
|
|
|
|
|
static func create(appId: Int) -> InstallOptions {
|
|
|
|
return InstallOptions(appId: UInt64(appId))
|
|
|
|
}
|
|
|
|
|
|
|
|
static func evaluate(m: CommandMode) -> Result<InstallOptions, CommandantError<MASError>> {
|
|
|
|
return create
|
2015-12-30 21:20:25 +00:00
|
|
|
<*> m <| Option(key: "", defaultValue: nil, usage: "the app ID to install")
|
2015-08-21 13:02:36 +00:00
|
|
|
}
|
|
|
|
}
|