Пример #1
0
func (e *env) Run(args ...string) (out, err []byte, exitCode int) {
	outbuf := new(bytes.Buffer)
	errbuf := new(bytes.Buffer)
	os.Args = append(os.Args[:1], args...)
	cmdmain.Stdout, cmdmain.Stderr = outbuf, errbuf
	if e.stdin == nil {
		cmdmain.Stdin = strings.NewReader("")
	} else {
		cmdmain.Stdin = e.stdin
	}
	exitc := make(chan int, 1)
	cmdmain.Exit = func(code int) {
		exitc <- code
		runtime.Goexit()
	}
	go func() {
		cmdmain.Main()
		cmdmain.Exit(0)
	}()
	select {
	case exitCode = <-exitc:
	case <-time.After(e.timeout()):
		panic("timeout running command")
	}
	out = outbuf.Bytes()
	err = errbuf.Bytes()
	return
}
Пример #2
0
func main() {
	cmdmain.CheckCwd = checkCamliSrcRoot
	cmdmain.CheckModtime = func() error {
		if err := checkModtime(); err != nil {
			log.Printf("Skipping freshness check: %v", err)
		}
		return nil
	}

	// TODO(mpl): usage error is not really correct for devcam.
	// See if I can reimplement it while still using cmdmain.Main().
	cmdmain.Main()
}
Пример #3
0
func main() {
	err := cmdmain.Main()
	// TODO(mpl): see how errors go with other camtool modes
	//  and move some of this accordingly to cmdmain.
	previousErrors := wereErrors
	if err != nil {
		wereErrors = true
		if !previousErrors {
			log.Printf("Error: %v", err)
		}
	}
	if wereErrors {
		cmdmain.Exit(2)
	}
}
Пример #4
0
func (e *env) Run(args ...string) (out, err []byte, exitCode int) {
	outbuf := new(bytes.Buffer)
	errbuf := new(bytes.Buffer)
	cmdmain.Stdout, cmdmain.Stderr = outbuf, errbuf
	exitc := make(chan int, 1)
	cmdmain.Exit = func(code int) {
		exitc <- code
		runtime.Goexit()
	}
	go func() {
		cmdmain.Main()
		cmdmain.Exit(0)
	}()
	select {
	case exitCode = <-exitc:
	case <-time.After(15 * time.Second):
		panic("timeout running command")
	}
	out = outbuf.Bytes()
	err = errbuf.Bytes()
	return
}
Пример #5
0
func main() {
	cmdmain.Main()
}
Пример #6
0
func main() {
	checkCamliSrcRoot()
	// TODO(mpl): usage error is not really correct for devcam.
	// See if I can reimplement it while still using cmdmain.Main().
	cmdmain.Main()
}
Пример #7
0
func main() {
	err := cmdmain.Main()
	if err != nil {
		cmdmain.Exit(2)
	}
}