Giter Site home page Giter Site logo

reactivetask's Introduction

ReactiveTask

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

let strings = [ "foo\n", "bar\n", "buzz\n", "fuzz\n" ]
let input = SignalProducer<Data, NoError>(values: strings.map { $0.data(using: .utf8)! })
let task = Task("/usr/bin/sort")

// Run the task, ignoring the output, and do something with the final result.
let result: 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 in
        return SignalProducer(value: String(data: data, encoding: .utf8))
    }
    .startWithNext { (event: TaskEvent) in
        switch event {
        case let .launch(task):
            print("launched task: \(task)")

        case let .standardError(data):
            print("stderr: \(data)")

        case let .standardOutput(data):
            print("stdout: \(data)")

        case let .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.

reactivetask's People

Contributors

andrewsb avatar ikesyo avatar iv-mexx avatar jspahrsummers avatar mattprowse avatar mdiep avatar nachosoto avatar norio-nomura avatar rahul0x24 avatar robb avatar robrix avatar tmspzz avatar younata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reactivetask's Issues

Better Readme

The README.md is a little bit confusing.
I created this iOS Open source Readme Template so you can take a look on how to better organize.
If you want, I can help you to organize the README.md.

What are your thoughts?

Providing interactive prompt input

Hi, I'm trying to figure out if there is a way to simulate interactive input as a reaction to the standard output.

For example, imagine calling $ git add -p with a bunch of unstaged changes, normally it'll produce something like

diff --git a/Hello world! b/Hello world!
index d45509a..b8f14f0 100644
--- a/Hello world!  
+++ b/Hello world!  
@@ -1,7 +1,3 @@
-
-
-
-
        Hello world!


Stage this hunk [y,n,q,a,d,/,e,?]? 

Let's say I want to response with y\n after analyzing output. Am I correct that currently there is no way to provide such a response? From what I understood, normally, I'd write into the standard input of the task. Do you think it's a good idea to add a case to TaskEvent providing you with a chance to write into the task after output was provided?
I didn't find anything similar in the carthage, but I might've missed it

Update it seems like it might be impossible according to several sources: http://www.cocoabuilder.com/archive/cocoa/64719-nstask-nspipe-and-interactive-unix-command.html

New Release

I really want to get the recent API changes and the RAC updates into Carthage. Would anyone object to me releasing master as 0.9?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.