Skip to content

Instantly share code, notes, and snippets.

@0xch4z
Created October 16, 2017 05:49
Show Gist options
  • Select an option

  • Save 0xch4z/044d15ed4466a88150c9ba7d65affb05 to your computer and use it in GitHub Desktop.

Select an option

Save 0xch4z/044d15ed4466a88150c9ba7d65affb05 to your computer and use it in GitHub Desktop.
//
// main.swift
// Open Applications
//
// Created by Charles Kenney on 10/16/17.
// Copyright © 2017 Charles Kenney. All rights reserved.
//
import Foundation
import Cocoa
func openApp(named name: String) -> Bool {
return NSWorkspace.shared.launchApplication(name)
}
func main() {
while true {
print("\n")
print("enter an application to open: ", terminator: "")
let appName = readLine()!
let result = openApp(named: appName)
print("\(result ? "Successfully launched app:" : "Failed to launch app:") \(appName)")
}
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment