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:
commit
fd5ae09f84
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user