Skip to content

Commit

Permalink
Add update alias
Browse files Browse the repository at this point in the history
Add `update` alias for `brew upgrade mas`. See mas-cli#281.
  • Loading branch information
danielbayley committed Jun 16, 2020
1 parent 7f4689b commit 1c736a8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions MasKit/Commands/Update.swift
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
}
}
1 change: 1 addition & 0 deletions mas/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ registry.register(SignOutCommand())
registry.register(UninstallCommand())
registry.register(RemoveCommand())
registry.register(RmCommand())
registry.register(UpdateCommand())
registry.register(UpgradeCommand())
registry.register(VendorCommand())
registry.register(VersionCommand())
Expand Down

0 comments on commit 1c736a8

Please sign in to comment.