forked from mas-cli/mas
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add `update` alias for `brew upgrade mas`. See mas-cli#281.
- Loading branch information
1 parent
7f4689b
commit 1c736a8
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Update.swift | ||
// mas-cli | ||
// | ||
// Created by Andrew Naylor on 30/12/2015. | ||
// Copyright © 2015 Andrew Naylor. All rights reserved. | ||
// | ||
|
||
import Commandant | ||
import Foundation | ||
|
||
/// Command which updates mas. | ||
public struct UpdateCommand: CommandProtocol { | ||
public typealias Options = NoOptions<MASError> | ||
public let verb = "update" | ||
public let function = "Update MAS" | ||
|
||
private let appLibrary: AppLibrary | ||
|
||
/// Public initializer. | ||
/// - Parameter appLibrary: AppLibrary manager. | ||
public init() { | ||
self.init(appLibrary: MasAppLibrary()) | ||
} | ||
|
||
/// Internal initializer. | ||
/// - Parameter appLibrary: AppLibrary manager. | ||
init(appLibrary: AppLibrary = MasAppLibrary()) { | ||
self.appLibrary = appLibrary | ||
} | ||
|
||
/// Runs the command. | ||
public func run(_: Options) -> Result<(), MASError> { | ||
print("Updating MAS…") | ||
|
||
let task = Process() | ||
task.launchPath = getenv("HOMEBREW_BREW_FILE") | ||
task.arguments = ["upgrade", "mas"] | ||
//let pipe = Pipe() | ||
//task.standardOutput = pipe | ||
//task.standardError = pipe | ||
task.launch() | ||
task.waitUntilExit() | ||
return task.terminationStatus | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters