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
class ViewController: NSViewController { | |
@IBOutlet private weak var textField: NSTextField! | |
@IBOutlet private weak var textView: NSTextView! | |
private var bashService = BashService() | |
@IBAction func execute(_ sender: Any) { | |
bashService.execute(textField.stringValue) { response in | |
DispatchQueue.main.async { |
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
import Foundation | |
import SecurityFoundation | |
import ServiceManagement | |
final class BashService { | |
// MARK: Private | |
private var connection: NSXPCConnection? | |
private var authorization: SFAuthorization? |
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
import Foundation | |
final class Service: NSObject { | |
// MARK: Private | |
private let listener: NSXPCListener | |
private var connections = [NSXPCConnection]() | |
override init() { | |
listener = NSXPCListener(machServiceName: Keys.machServiceName) |
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
import Cocoa | |
class ViewController: NSViewController { | |
@IBOutlet private weak var textField: NSTextField! | |
@IBOutlet private weak var textView: NSTextView! | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.chersky.service</string> | |
<key>MachServices</key> | |
<dict> | |
<key>com.chersky.service</key> | |
<true/> |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>CFBundleIdentifier</key> | |
<string>com.chersky.service</string> | |
<key>CFBundleInfoDictionaryVersion</key> | |
<string>6.0</string> | |
<key>CFBundleName</key> | |
<string>com.chersky.service</string> |
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
import Foundation | |
final class Bash { | |
// MARK: Private | |
private var operations: [Process] | |
/// | |
/// - Parameters: | |
/// - domain: Root folder for storing output files (Pipe is limited my itself capacity so you may send output data to an file) |
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
import Foundation | |
public struct Keys { | |
static let machServiceName = "com.chersky.service" | |
} | |
@objc | |
protocol ServiceProtocol { | |
func bash(_ args: [String], completion: @escaping (String) -> Void) | |
} |
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
import ServiceManagement | |
import SecurityFoundation | |
final class ServiceManagment { | |
enum Error: LocalizedError { | |
case canceledByUser | |
} | |
private init() {} |