Esempio n. 1
0
func main() {
	defer handlePanic()
	// Eventually, these should become flags on the top level application
	//sous.Log.Info.SetOutput(os.Stderr)
	//sous.Log.Debug.SetOutput(os.Stderr)
	log.SetFlags(log.Flags() | log.Lshortfile)

	c, err := cli.NewSousCLI(Sous, os.Stdin, os.Stdout, os.Stderr)
	if err != nil {
		die(err)
	}

	result := c.Invoke(os.Args)
	exitCode := result.ExitCode()

	os.Exit(exitCode)
}
Esempio n. 2
0
// NewTerminal creates a new test terminal.
func NewTerminal(t *testing.T, vstr string) *Terminal {
	v := semv.MustParse(vstr)
	baseout := TestOutput{"stdout", &bytes.Buffer{}, t}
	baseerr := TestOutput{"stderr", &bytes.Buffer{}, t}
	combined := TestOutput{"combined output", &bytes.Buffer{}, t}

	in := &bytes.Buffer{}
	out := io.MultiWriter(baseout.Buffer, combined.Buffer)
	err := io.MultiWriter(baseerr.Buffer, combined.Buffer)

	s := &cli.Sous{Version: v}
	c, er := cli.NewSousCLI(s, in, out, err)
	if er != nil {
		panic(er)
	}

	return &Terminal{c, baseout, baseerr, combined, []string{}, t}
}