Ejemplo n.º 1
0
func main() {
	defer app.Exiting()
	app.New()
	app.SetIO(app.OSIn(), 0)
	xp.Run()
	app.Exits(nil)
}
Ejemplo n.º 2
0
func TestParseStdin(t *testing.T) {
	r, w, err := os.Pipe()
	if err != nil {
		t.Fatalf("pipe: %s", err)
	}
	fd, err := os.Open("example")
	if err != nil {
		t.Fatalf("ex: %s", err)
	}
	defer fd.Close()
	go func() {
		io.Copy(w, fd)
		w.Close()
	}()
	os.Stdin = r
	app.New()
	defer app.Exiting()
	ql := func() {
		c := app.AppCtx()
		c.Debug = testing.Verbose()
		app.SetIO(app.OSIn(), 0)
		Run()
	}
	x := app.Go(ql, "ql", "-n")
	<-x.Wait
	if x.Sts != nil {
		t.Fatalf("did fail")
	}
}