Skip to content

Carthage/ReactiveTask

Repository files navigation

ReactiveTask

ReactiveTask is a Swift framework for launching shell tasks (processes), built using ReactiveSwift.

letstrings=["foo\n","bar\n","buzz\n","fuzz\n"]letinput=SignalProducer<Data,NoError>(values: strings.map{ $0.data(using:.utf8)! })lettask=Task("/usr/bin/sort") // Run the task, ignoring the output, and do something with the final result. letresult:Result<String,TaskError>?= task.launch(standardInput: input).ignoreTaskData().map{String(data: $0, encoding:.utf8)}.ignoreNil().single()print("Output of `\(task)`: \(result?.value ??"")") // Start the task and print all the events, which includes all the output // that was received. task.launch(standardInput: input).flatMapTaskEvents(.concat){ data inreturnSignalProducer(value:String(data: data, encoding:.utf8))}.startWithNext{(event:TaskEvent)inswitch event {caselet.launch(task):print("launched task: \(task)")caselet.standardError(data):print("stderr: \(data)")caselet.standardOutput(data):print("stdout: \(data)")caselet.success(string):print("value: \(string ??"")")}}

For examples of how to use ReactiveTask, see the Xcode and Git integration code from the CarthageKit framework.

License

ReactiveTask is released under the MIT license.

About

Flexible, stream-based abstraction for launching processes

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 13