mirror of
https://github.com/gechandesu/runcmd.git
synced 2026-02-13 08:41:51 +03:00
examples: Remove io.string_reader
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import io.string_reader
|
import io
|
||||||
import rand
|
import rand
|
||||||
import runcmd
|
import runcmd
|
||||||
import time
|
import time
|
||||||
@@ -20,7 +20,7 @@ fn main() {
|
|||||||
mut child_stdout := cmd.stdout()!
|
mut child_stdout := cmd.stdout()!
|
||||||
|
|
||||||
// Prepare reader to store command output.
|
// Prepare reader to store command output.
|
||||||
mut output := string_reader.StringReader.new(reader: child_stdout)
|
mut output := io.new_buffered_reader(reader: child_stdout)
|
||||||
|
|
||||||
// Start stdout reading in a coroutine.
|
// Start stdout reading in a coroutine.
|
||||||
//
|
//
|
||||||
@@ -56,4 +56,6 @@ fn main() {
|
|||||||
|
|
||||||
// wait() will close the child stdout file desciptor by itself.
|
// wait() will close the child stdout file desciptor by itself.
|
||||||
cmd.wait()!
|
cmd.wait()!
|
||||||
|
|
||||||
|
println('Child state: ${cmd.state}')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import io.string_reader
|
import io
|
||||||
import runcmd
|
import runcmd
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -14,7 +14,7 @@ fn main() {
|
|||||||
|
|
||||||
// Setup StringReader with stdout input. Note the cmd.stdout()! call, it
|
// Setup StringReader with stdout input. Note the cmd.stdout()! call, it
|
||||||
// returns the io.Reader interface and reads child process stdout file descriptor.
|
// returns the io.Reader interface and reads child process stdout file descriptor.
|
||||||
mut reader := string_reader.StringReader.new(reader: cmd.stdout()!)
|
mut reader := io.new_buffered_reader(reader: cmd.stdout()!)
|
||||||
|
|
||||||
// Read sdtout line by line until EOF.
|
// Read sdtout line by line until EOF.
|
||||||
for {
|
for {
|
||||||
|
|||||||
Reference in New Issue
Block a user