Last active
June 16, 2017 13:45
-
-
Save reitermarkus/a313fad0d1a05b2e760c1fc740abc379 to your computer and use it in GitHub Desktop.
Revisions
-
reitermarkus revised this gist
Jun 16, 2017 . 1 changed file with 16 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/usr/bin/swift import Cocoa import Foundation @@ -7,14 +7,26 @@ 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) } -
reitermarkus created this gist
Jun 16, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ #!/usr/bin/xcrun swift import Cocoa import Foundation DispatchQueue.main.async { let arguments = CommandLine.arguments.dropFirst() let urls = arguments.map { URL(fileURLWithPath: $0) } NSWorkspace.shared.recycle(urls) { (dict, error) in guard error != nil else { exit(0) } let untrashedURLS = urls.filter { !dict.keys.contains($0) } untrashedURLS.forEach { fputs($0.path + "\n", stderr) } exit(1) } } RunLoop.main.run()