示例#1
0
func main() {
	defer app.Exiting()
	app.New()
	app.Close(0)
	ql.Run()
	app.Exits(nil)
}
示例#2
0
func (c *qCmd) start(txt string) error {
	c.Lock()
	if c.ctx != nil {
		c.Unlock()
		return fmt.Errorf("%s: one cmd is enough", c)
	}
	c.txt = txt
	var in chan interface{}
	if c.in.Len() > 0 {
		c.in.c = make(chan interface{}, len(c.in.msgs))
		for _, m := range c.in.msgs {
			c.in.c <- m
		}
		close(c.in.c)
		in = c.in.c
	}
	outfn := func(c *qCmd, io *qIO, outc chan interface{}) {
		for m := range outc {
			c.Lock()
			io.addOut(m)
			c.Unlock()
		}
		io.eof = true
		io.wakeup()
	}
	out := make(chan interface{})
	go outfn(c, c.out, out)
	err := make(chan interface{})
	go outfn(c, c.err, err)
	c.e.runc <- func() {
		c.ctx = app.Go(func() {
			c.Unlock()
			app.DupDot()
			app.DupEnv()
			app.NewIO(nil)
			app.SetIO(in, 0)
			app.SetIO(out, 1)
			app.SetIO(err, 2)
			ql.Run()
		}, "ql", "-c", c.txt)
	}
	return nil
}