PT-73 Fixed help flag

This commit is contained in:
Carlos Salguero
2017-02-23 11:14:45 -03:00
parent 169cbbdec0
commit 4089b5e4c2
2 changed files with 13 additions and 5 deletions

View File

@@ -155,8 +155,7 @@ func main() {
log.Errorf("error processing commad line arguments: %s", err)
os.Exit(1)
}
if opts.Help {
getopt.Usage()
if opts == nil && err == nil {
return
}
@@ -540,7 +539,8 @@ func getOptions() (*options, error) {
gop.Parse(gop.Args())
}
if opts.Help {
return opts, nil
gop.PrintUsage(os.Stdout)
return nil, nil
}
if gop.IsSet("order-by") {

View File

@@ -143,6 +143,9 @@ func main() {
log.Errorf("cannot get parameters: %s", err.Error())
os.Exit(2)
}
if opts == nil && err == nil {
return
}
if opts.Help {
getopt.Usage()
@@ -784,8 +787,8 @@ func externalIP() (string, error) {
return "", errors.New("are you connected to the network?")
}
func parseFlags() (options, error) {
opts := options{
func parseFlags() (*options, error) {
opts := &options{
Host: DEFAULT_HOST,
LogLevel: DEFAULT_LOGLEVEL,
RunningOpsSamples: DEFAULT_RUNNINGOPSSAMPLES,
@@ -828,6 +831,11 @@ func parseFlags() (options, error) {
}
opts.Password = string(pass)
}
if opts.Help {
gop.PrintUsage(os.Stdout)
return nil, nil
}
return opts, nil
}