Last active
June 16, 2017 13:45
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
#!/usr/bin/swift | |
import Cocoa | |
import Foundation | |
DispatchQueue.main.async { | |
let arguments = CommandLine.arguments.dropFirst() | |
let urls = arguments.map { URL(fileURLWithPath: $0) } | |
#if swift(>=4.0) | |
let workspace = NSWorkspace.shared | |
#else | |
let workspace = NSWorkspace.shared() | |
#endif | |
workspace.recycle(urls) { (dict, error) in | |
let trashedURLs = dict.keys | |
trashedURLs.forEach { | |
print($0.path) | |
} | |
guard error != nil else { | |
exit(0) | |
} | |
let untrashedURLs = urls.filter { !trashedURLs.contains($0) } | |
untrashedURLs.forEach { | |
fputs($0.path + "\n", stderr) | |
} | |
exit(1) | |
} | |
} | |
RunLoop.main.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment