A Swift package for interacting with command line interfaces.
Create an interface with
let interface = Interface(executableURL: ...)
Create a command by implementing the Command
and CommandResponse
protocols.
struct VersionCommand: Command {
typealias Response = VersionCommandResponse
var arguments: [String] {
return ["--version"]
}
}
public struct VersionCommandResponse: CommandResponse {
public let version: String
public init?(response: String?) {
guard let response = response else { return nil }
version = response
}
}
Send commands to the executable through the interface.
do {
try interface.send(VersionCommand()) { response in
print("Version: \(response.version ?? "N/A")")
}
}
catch {
print("Error sending command: \(error)")
}
link |
Stars: 0 |
Last commit: 2 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics