// retoor <retoor@molodetz.nl>
import "pexpect" for Spawn, Pexpect
var child = Spawn.new("echo 'hello world'")
var result = child.expect(["world", "hello"])
System.print(result) // expect: 1
System.print(child.after) // expect: hello
child.close()
child = Spawn.new("printf 'abc123def'")
result = child.expectExact(["123"])
System.print(result) // expect: 0
System.print(child.before) // expect: abc
System.print(child.after) // expect: 123
child.close()
child = Spawn.new("echo 'test multiple patterns'")
result = child.expect(["foo", "bar", "multiple"])
System.print(result) // expect: 2
child.close()