VOL-2236 handle output of help message
Change-Id: I4fc686608f6b369928a723dc8a2acc2dfe9d5a23
diff --git a/cmd/voltctl/voltctl.go b/cmd/voltctl/voltctl.go
index 8a342ca..54a4cad 100644
--- a/cmd/voltctl/voltctl.go
+++ b/cmd/voltctl/voltctl.go
@@ -16,6 +16,7 @@
package main
import (
+ "fmt"
flags "github.com/jessevdk/go-flags"
"github.com/opencord/voltctl/internal/pkg/commands"
"os"
@@ -71,9 +72,13 @@
_, ok := err.(*flags.Error)
if ok {
real := err.(*flags.Error)
+ // Send help message to stdout, else to stderr
if real.Type == flags.ErrHelp {
- return
+ parser.WriteHelp(os.Stdout)
+ } else {
+ fmt.Fprintf(os.Stderr, "%s\n", real.Error())
}
+ return
} else {
commands.Error.Fatal(commands.ErrorToString(err))
}