Skip to content
Browse files

Add example of input/output

  • Loading branch information...
1 parent dfa6fb7 commit a4b7a9a4338b795cbceb8b0399c1d32ce02c6068 @gdb committed Jan 22, 2013
Showing with 18 additions and 4 deletions.
  1. +12 −4 README.md
  2. +6 −0 examples/dots.sh
View
16 README.md
@@ -58,10 +58,18 @@ are arbitrary symbols):
runner.data(:stdout) # "hi\n"
runner.data(:stderr) # ""
-Support for controlled input isn't quite ready, but the syntax will be
-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
-quite decided on the right API for this yet.
+## Controlled input
+
+You can easily read and write data interactively:
+
+ >> 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
View
6 examples/dots.sh
@@ -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.
Something went wrong with that request. Please try again.