Skip to content

Commit

Permalink
Fixing the Help Message
Browse files Browse the repository at this point in the history
  • Loading branch information
AKSarav committed Mar 29, 2024
1 parent f86fa9c commit 3488b4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
11 changes: 7 additions & 4 deletions utils/validations.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package utils

import "strings"

var ValidColors = map[string]bool{
"red": true,
"green": true,
Expand Down Expand Up @@ -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, ", ")+"]"
}

0 comments on commit 3488b4a

Please sign in to comment.