mirror of https://github.com/chzyer/readline.git
Added the write method to the Instance object so that it can be passed around as a io.Writer object.
This commit is contained in:
parent
8fcf9da96c
commit
800fa3d2b8
|
@ -1,12 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/chzyer/readline"
|
"github.com/traetox/readline"
|
||||||
)
|
)
|
||||||
|
|
||||||
func usage(w io.Writer) {
|
func usage(w io.Writer) {
|
||||||
|
@ -43,6 +44,8 @@ func main() {
|
||||||
}()
|
}()
|
||||||
case "bye":
|
case "bye":
|
||||||
goto exit
|
goto exit
|
||||||
|
case "write":
|
||||||
|
fmt.Fprintf(l, "look, i am writer too\n")
|
||||||
case "":
|
case "":
|
||||||
default:
|
default:
|
||||||
log.Println("you said:", strconv.Quote(line))
|
log.Println("you said:", strconv.Quote(line))
|
||||||
|
|
|
@ -44,3 +44,7 @@ func (i *Instance) Close() error {
|
||||||
i.o.Close()
|
i.o.Close()
|
||||||
return i.t.Close()
|
return i.t.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *Instance) Write(b []byte) (int, error) {
|
||||||
|
return i.o.Stderr().Write(b)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue