jawher / mow.cli

A versatile library for building CLI applications in Go
MIT License
871 stars 55 forks source link

Custom exiter #112

Open usernametaken opened 3 years ago

usernametaken commented 3 years ago

in cli.go var exiter = func(code int) { os.Exit(code) }

It would be great is this variable is exported so it can be overridden with a custom func

var Exiter = func(code int) { os.Exit(code) }

The reason I need this is because I do some initialization (e.g. open DB & log) in my application before I call cli Run It the cmdline parameters are not complete... help is displayed BUT the After func is not called (so I can't do it there)

I need to to override the exiter to finalize my application (e.g. close the DB connection & log)

The egs are just hypothetical examples but should convey the basic idea