From 3488b4aa0aa86845e4c102aead2b7338045334a3 Mon Sep 17 00:00:00 2001 From: Sarav Date: Sat, 30 Mar 2024 00:20:26 +0530 Subject: [PATCH] Fixing the Help Message --- main.go | 4 ++-- utils/validations.go | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index ffe2a54..0953cb9 100644 --- a/main.go +++ b/main.go @@ -36,13 +36,13 @@ func usage() { // print in fine columns with fixed width displayfmt := "%-20s %-20s\n" fmt.Printf(displayfmt, " --help", "to display help") - fmt.Printf(displayfmt, " --sortby", "sort by ", utils.PrintValidSorts) + fmt.Printf(displayfmt, " --sortby", utils.PrintValidSorts()) fmt.Printf(displayfmt, " --filternodes", "filter based on node name") fmt.Printf(displayfmt, " --filtercolor", "filter based on color category <30 Green, >30 <70 Orange, >70 Red") fmt.Printf(displayfmt, " --filterlabels", "filter based on labels") fmt.Printf(displayfmt, " --desc", "to enable reverse sort") fmt.Printf(displayfmt, " --debug", "enable debug mode") - fmt.Printf(displayfmt, " --metrics", "choose which metrics", utils.PrintValidMetrics()) + fmt.Printf(displayfmt, " --metrics", utils.PrintValidMetrics()) os.Exit(1) } diff --git a/utils/validations.go b/utils/validations.go index 3ff4c04..b1aeb00 100644 --- a/utils/validations.go +++ b/utils/validations.go @@ -1,5 +1,7 @@ package utils +import "strings" + var ValidColors = map[string]bool{ "red": true, "green": true, @@ -45,18 +47,19 @@ func PrintValidColors() []string { return result } -func PrintValidMetrics() []string { +func PrintValidMetrics() string { var result []string for k := range ValidMetrics { result = append(result, k) } - return result + return "Choose one of ["+strings.Join(result, ", ")+"]" } -func PrintValidSorts() []string { +func PrintValidSorts() string { var result []string for k := range ValidSorts { result = append(result, k) } - return result + // return comma separated string + return "Choose one of ["+strings.Join(result, ", ")+"]" }