Merge pull request #2969 from git-lfs/exit-on-unknown-subcommand

commands/run.go: exit 127 on unknown sub-command
This commit is contained in:
Taylor Blau 2018-04-12 16:07:31 -07:00 committed by GitHub
commit fd5ae09f84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

@ -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) {

@ -32,6 +32,7 @@ func main() {
}
}()
commands.Run()
code := commands.Run()
once.Do(commands.Cleanup)
os.Exit(code)
}