Created
June 2, 2016 09:11
-
-
Save amake/cd3a9695cdef9a0da1f87e402950408e to your computer and use it in GitHub Desktop.
A Swift CLI tool for calling arbitrary OS X Services
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
// | |
// main.swift | |
// doservice | |
// | |
// Created by Aaron Madlon-Kay on 6/2/16. | |
// Copyright © 2016 Aaron Madlon-Kay. All rights reserved. | |
// | |
import Foundation | |
import AppKit | |
let args = NSProcessInfo.processInfo().arguments | |
guard args.count == 4 else { | |
print("Usage: doservice <service name> <data type> <argument>") | |
print("Example: doservice \"New Terminal at Folder\" public.file-url /foo/bar") | |
exit(1) | |
} | |
let pb = NSPasteboard.pasteboardWithUniqueName() | |
pb.setString(args[3], forType: args[2]) | |
NSPerformService(args[1], pb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment