mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-12 07:44:17 +00:00
Improve handling of cmdline errors (#91)
Improve handling of cmdline errors
This commit is contained in:
parent
607c90a0a9
commit
85b30f8c2a
2 changed files with 16 additions and 11 deletions
|
|
@ -48,15 +48,23 @@ func processResults(cancel context.CancelFunc, o output.Output, validationResult
|
|||
|
||||
func realMain() int {
|
||||
cfg, out, err := config.FromFlags(os.Args[0], os.Args[1:])
|
||||
if cfg.Help {
|
||||
return 0
|
||||
} else if cfg.Version {
|
||||
if out != "" {
|
||||
o := os.Stderr
|
||||
errCode := 1
|
||||
if cfg.Help {
|
||||
o = os.Stdout
|
||||
errCode = 0
|
||||
}
|
||||
fmt.Fprintln(o, out)
|
||||
return errCode
|
||||
}
|
||||
|
||||
if cfg.Version {
|
||||
fmt.Println(version)
|
||||
return 0
|
||||
} else if out != "" {
|
||||
fmt.Println(out)
|
||||
return 1
|
||||
} else if err != nil {
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed parsing command line: %s\n", err.Error())
|
||||
return 1
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue