diff --git a/commands/run.go b/commands/run.go index 5196fc3a..18f3ef90 100644 --- a/commands/run.go +++ b/commands/run.go @@ -50,7 +50,9 @@ func RegisterCommand(name string, runFn func(cmd *cobra.Command, args []string), // Run initializes the 'git-lfs' command and runs it with the given stdin and // command line args. -func Run() { +// +// It returns an exit code. +func Run() int { log.SetOutput(ErrorWriter) root := NewCommand("git-lfs", gitlfsCommand) @@ -73,8 +75,13 @@ func Run() { } } - root.Execute() + err := root.Execute() closeAPIClient() + + if err != nil { + return 127 + } + return 0 } func gitlfsCommand(cmd *cobra.Command, args []string) { diff --git a/git-lfs.go b/git-lfs.go index c185eea0..d8d66b41 100644 --- a/git-lfs.go +++ b/git-lfs.go @@ -32,6 +32,7 @@ func main() { } }() - commands.Run() + code := commands.Run() once.Do(commands.Cleanup) + os.Exit(code) }