mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Add an explicit help flag that exits with 0 (#3654)
`stash --help` exits with a non-zero exit code. Because `stash --help` is a legitimate invocation, it should return an exit code of zero. Adding an explicit help flag allows for exiting with a successful exit code.
This commit is contained in:
parent
8d3f632d4c
commit
85c893fd81
1 changed files with 8 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ type flagStruct struct {
|
||||||
configFilePath string
|
configFilePath string
|
||||||
cpuProfilePath string
|
cpuProfilePath string
|
||||||
nobrowser bool
|
nobrowser bool
|
||||||
|
helpFlag bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetInstance() *Instance {
|
func GetInstance() *Instance {
|
||||||
|
|
@ -40,6 +41,12 @@ func Initialize() (*Instance, error) {
|
||||||
var err error
|
var err error
|
||||||
initOnce.Do(func() {
|
initOnce.Do(func() {
|
||||||
flags := initFlags()
|
flags := initFlags()
|
||||||
|
|
||||||
|
if flags.helpFlag {
|
||||||
|
pflag.Usage()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
overrides := makeOverrideConfig()
|
overrides := makeOverrideConfig()
|
||||||
|
|
||||||
_ = GetInstance()
|
_ = GetInstance()
|
||||||
|
|
@ -126,6 +133,7 @@ func initFlags() flagStruct {
|
||||||
pflag.StringVarP(&flags.configFilePath, "config", "c", "", "config file to use")
|
pflag.StringVarP(&flags.configFilePath, "config", "c", "", "config file to use")
|
||||||
pflag.StringVar(&flags.cpuProfilePath, "cpuprofile", "", "write cpu profile to file")
|
pflag.StringVar(&flags.cpuProfilePath, "cpuprofile", "", "write cpu profile to file")
|
||||||
pflag.BoolVar(&flags.nobrowser, "nobrowser", false, "Don't open a browser window after launch")
|
pflag.BoolVar(&flags.nobrowser, "nobrowser", false, "Don't open a browser window after launch")
|
||||||
|
pflag.BoolVarP(&flags.helpFlag, "help", "h", false, "show this help text and exit")
|
||||||
|
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue