Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
hub/main.go /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
43 lines (37 sloc)
697 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//go:build go1.8 | |
// +build go1.8 | |
package main | |
import ( | |
"os" | |
"os/exec" | |
"syscall" | |
"github.com/github/hub/v2/commands" | |
"github.com/github/hub/v2/github" | |
"github.com/github/hub/v2/ui" | |
) | |
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() | |
} | |
return 1 | |
case *commands.ErrHelp: | |
ui.Println(err) | |
return 0 | |
default: | |
if errString := err.Error(); errString != "" { | |
ui.Errorln(err) | |
} | |
return 1 | |
} | |
} |