fix(gonf): fixed gonf -help fd output and return code to not error

This commit is contained in:
Julien Dessaux 2024-09-17 09:57:29 +02:00
parent aad0157b42
commit bae2d26671
Signed by: adyxax
GPG key ID: F92E51B86E07177E
3 changed files with 8 additions and 3 deletions

View file

@ -12,7 +12,7 @@ func (env *Env) cmdBuild() error {
where FLAG can be one or more of`, flag.ContinueOnError) where FLAG can be one or more of`, flag.ContinueOnError)
hostFlag := env.addHostFlag() hostFlag := env.addHostFlag()
env.flagSet.SetOutput(env.stderr) env.flagSet.SetOutput(env.stderr)
env.flagSet.Parse(env.args) _ = env.flagSet.Parse(env.args)
if env.helpMode { if env.helpMode {
env.flagSet.SetOutput(env.stdout) env.flagSet.SetOutput(env.stdout)
env.flagSet.Usage() env.flagSet.Usage()

View file

@ -11,7 +11,7 @@ func (env *Env) cmdDeploy() error {
where FLAG can be one or more of`, flag.ContinueOnError) where FLAG can be one or more of`, flag.ContinueOnError)
hostFlag := env.addHostFlag() hostFlag := env.addHostFlag()
env.flagSet.SetOutput(env.stderr) env.flagSet.SetOutput(env.stderr)
env.flagSet.Parse(env.args) _ = env.flagSet.Parse(env.args)
if env.helpMode { if env.helpMode {
env.flagSet.SetOutput(env.stdout) env.flagSet.SetOutput(env.stdout)
env.flagSet.Usage() env.flagSet.Usage()

View file

@ -41,9 +41,14 @@ where FLAG can be one or more of`, flag.ContinueOnError)
env.flagSet.BoolVar(&env.helpMode, "help", false, "show contextual help") env.flagSet.BoolVar(&env.helpMode, "help", false, "show contextual help")
env.flagSet.StringVar(&env.configDir, "config", "", "(REQUIRED for most commands) path to a gonf configurations repository (overrides the GONF_CONFIG environment variable)") env.flagSet.StringVar(&env.configDir, "config", "", "(REQUIRED for most commands) path to a gonf configurations repository (overrides the GONF_CONFIG environment variable)")
env.flagSet.SetOutput(env.stderr) env.flagSet.SetOutput(env.stderr)
env.flagSet.Parse(env.args[1:]) _ = env.flagSet.Parse(env.args[1:])
if env.flagSet.NArg() < 1 { if env.flagSet.NArg() < 1 {
if env.helpMode {
env.flagSet.SetOutput(env.stdout)
env.flagSet.Usage()
return nil
}
env.flagSet.Usage() env.flagSet.Usage()
return fmt.Errorf("no command given") return fmt.Errorf("no command given")
} }