Each command calls os.Exit() when finishing, as does RunMain(). The RunMain() code is not, currently, actually reachable, as the command calling os.Exit() terminates program execution. This is unfortunate, as the RunMain() code also logs program termination, and the commands don't. Since the program termination logging depends on knowing when the program began execution, migrating that logic into a function that each command could call is not trivial, and new commands could easily forget to call it. Therefore, the commands should simply return an error that RunMain() would receive and understand, logging the embedded information and calling os.Exit() with an appropriate value.
Each command calls
os.Exit()
when finishing, as doesRunMain()
. TheRunMain()
code is not, currently, actually reachable, as the command callingos.Exit()
terminates program execution. This is unfortunate, as theRunMain()
code also logs program termination, and the commands don't. Since the program termination logging depends on knowing when the program began execution, migrating that logic into a function that each command could call is not trivial, and new commands could easily forget to call it. Therefore, the commands should simply return an error thatRunMain()
would receive and understand, logging the embedded information and callingos.Exit()
with an appropriate value.