Skip to content

Commit

Permalink
Add example of input/output
Browse files Browse the repository at this point in the history
  • Loading branch information
gdb committed Jan 22, 2013
1 parent dfa6fb7 commit a4b7a9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ are arbitrary symbols):
runner.data(:stdout) # "hi\n" runner.data(:stdout) # "hi\n"
runner.data(:stderr) # "" runner.data(:stderr) # ""


Support for controlled input isn't quite ready, but the syntax will be ## Controlled input
similar to the above. I want to support interactivity (so being able
to write data, read some data, and then write more data), and haven't You can easily read and write data interactively:
quite decided on the right API for this yet.
>> runner = Rubysh('examples/dots.sh', Rubysh.>).run_async
=> Rubysh::Runner: examples/dots.sh >:stdout (readers: :stdout, pid: 78296)
>> runner.read(:how => :partial) # block until some output available
=> ".\n.\n.\n.\n.\n.\n.\n.\n.\n"
>> runner.read(:how => :nonblock)
=> ""
>> runner.read # block until all output available
=> [truncated]


## API ## API


Expand Down
6 changes: 6 additions & 0 deletions examples/dots.sh
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

for i in $(seq 1 100); do
echo .
sleep 1
done

0 comments on commit a4b7a9a

Please sign in to comment.