hub/main.go

44 строки
683 B
Go
Исходник Обычный вид История

2017-05-17 14:34:13 +03:00
// +build go1.8
2013-04-09 08:53:13 +04:00
package main
import (
"os"
"os/exec"
"syscall"
2014-02-10 20:22:36 +04:00
"github.com/github/hub/commands"
"github.com/github/hub/github"
"github.com/github/hub/ui"
2013-04-30 06:45:57 +04:00
)
2013-04-22 07:36:21 +04:00
2013-04-09 08:53:13 +04:00
func main() {
defer github.CaptureCrash()
err := commands.CmdRunner.Execute(os.Args)
exitCode := handleError(err)
os.Exit(exitCode)
}
func handleError(err error) int {
if err == nil {
return 0
}
switch e := err.(type) {
case *exec.ExitError:
if status, ok := e.Sys().(syscall.WaitStatus); ok {
return status.ExitStatus()
} else {
return 1
}
case *commands.ErrHelp:
ui.Println(err)
return 0
default:
if errString := err.Error(); errString != "" {
ui.Errorln(err)
}
return 1
}
}