Release 0.3.0
A shell interface built as a thin abstraction layer over Foundation’s Process.
Process
// -- Simple use case example: let shell = ExecuteCommand() let result = shell.execute(command: "cat", arguments: ["/tmp/log.0.txt", "/tmp/log.1.txt"], waitUntilExit: true) // -- Customization example: var context = TaskContext() context.environment = ["HOME": "/Users/me"] context.workingDirectory = "/tmp/" let bash = ExecuteCommand(pathToShell: "/bin/bash") _ = bash.execute(command: "curl", arguments: ["http://example.org"], context: context, waitUntilExit:false) // -- Error reporting examples: print(result.standardError) guard let terminationStatus = result.terminationStatus else { throw TaskFailure.stillRunning(domain: #function, code: #line) } guard terminationStatus == 0 else { throw TaskFailure.nonzeroTerminationStatus( domain: #function, code: #line, terminationStatus: terminationStatus, uncaughtSignal: result.terminatedDueUncaughtSignal ) } guard !result.standardOutput.isEmpty else { throw TaskFailure.emptyOutput(domain: #function, code: #line) }
ShellInterface is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ShellInterface"
ShellInterface is available under the MIT license. See the LICENSE file for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
ShellInterface
A shell interface built as a thin abstraction layer over Foundation’s
Process
.Usage
Installation
ShellInterface is available through CocoaPods. To install it, simply add the following line to your Podfile:
License
ShellInterface is available under the MIT license. See the LICENSE file for more info.
Alternatives