2017-05-17 14:34:13 +03:00
|
|
|
// +build go1.8
|
|
|
|
|
2013-04-09 08:53:13 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-09-11 00:08:48 +03:00
|
|
|
"os"
|
2019-01-16 06:19:49 +03:00
|
|
|
"os/exec"
|
|
|
|
"syscall"
|
2016-09-11 00:08:48 +03:00
|
|
|
|
2014-02-10 20:22:36 +04:00
|
|
|
"github.com/github/hub/commands"
|
|
|
|
"github.com/github/hub/github"
|
2016-09-11 00:08:48 +03:00
|
|
|
"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() {
|
2014-01-05 04:48:52 +04:00
|
|
|
defer github.CaptureCrash()
|
2019-01-16 06:19:49 +03:00
|
|
|
err := commands.CmdRunner.Execute(os.Args)
|
|
|
|
exitCode := handleError(err)
|
|
|
|
os.Exit(exitCode)
|
|
|
|
}
|
|
|
|
|
|
|
|
func handleError(err error) int {
|
|
|
|
if err == nil {
|
|
|
|
return 0
|
|
|
|
}
|
2014-01-05 04:48:52 +04:00
|
|
|
|
2019-01-16 06:19:49 +03:00
|
|
|
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
|
2016-09-11 00:08:48 +03:00
|
|
|
}
|
2013-05-24 02:21:18 +04:00
|
|
|
}
|