From 800fa3d2b8e24dfe7841247e523bdef48d99dc8d Mon Sep 17 00:00:00 2001 From: Kris Watts Date: Wed, 23 Sep 2015 21:22:26 -0600 Subject: [PATCH] Added the write method to the Instance object so that it can be passed around as a io.Writer object. --- example/main.go | 5 ++++- readline.go | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/example/main.go b/example/main.go index 92d334a..c467750 100644 --- a/example/main.go +++ b/example/main.go @@ -1,12 +1,13 @@ package main import ( + "fmt" "io" "log" "strconv" "time" - "github.com/chzyer/readline" + "github.com/traetox/readline" ) func usage(w io.Writer) { @@ -43,6 +44,8 @@ func main() { }() case "bye": goto exit + case "write": + fmt.Fprintf(l, "look, i am writer too\n") case "": default: log.Println("you said:", strconv.Quote(line)) diff --git a/readline.go b/readline.go index adf87bc..463357b 100644 --- a/readline.go +++ b/readline.go @@ -44,3 +44,7 @@ func (i *Instance) Close() error { i.o.Close() return i.t.Close() } + +func (i *Instance) Write(b []byte) (int, error) { + return i.o.Stderr().Write(b) +}