Is your feature request related to a problem? Please describe.
Currently, every cmd code uses log.Fatal to handle the exit of the program, this is really bad since it calls os.Exit directly and it is very hard to implement a stopper in the cmd.Run function.
Describe the solution you'd like
Use context.WithCancel to pass a cancellable context, the underlying functions can call cancel in case of an error that requires the entire program to exit.
Then cmd.Run can have a exit handler that can listen to this context to gracefully clean up its resources.
This context can also be used by underlying functions.
Is your feature request related to a problem? Please describe.
Currently, every cmd code uses
log.Fatalto handle the exit of the program, this is really bad since it callsos.Exitdirectly and it is very hard to implement a stopper in thecmd.Runfunction.Describe the solution you'd like
Use
context.WithCancelto pass a cancellable context, the underlying functions can callcancelin case of an error that requires the entire program to exit.Then
cmd.Runcan have a exit handler that can listen to this context to gracefully clean up its resources.This context can also be used by underlying functions.