mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
Don't stop installing applications after a failure
This commit is contained in:
parent
319300e7a1
commit
642e804e28
1 changed files with 17 additions and 3 deletions
|
@ -12,13 +12,27 @@ struct InstallCommand: CommandType {
|
|||
let function = "Install from the Mac App Store"
|
||||
|
||||
func run(options: Options) -> Result<(), MASError> {
|
||||
for id in options.appIds {
|
||||
// Try to download applications with given identifiers and collect results
|
||||
let results = options.appIds.map { (id) -> Result<(), MASError> in
|
||||
if let error = download(id) {
|
||||
return .Failure(error)
|
||||
} else {
|
||||
return .Success()
|
||||
}
|
||||
}
|
||||
|
||||
return .Success(())
|
||||
// See if at least one of the downloads failed
|
||||
let errorIndex = results.indexOf {
|
||||
if case .Failure(_) = $0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
// And return an overrall general failure if there're failed downloads
|
||||
if let _ = errorIndex {
|
||||
return .Failure(MASError(code: .DownloadFailed))
|
||||
} else {
|
||||
return .Success()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue