pokecli/internal/commands/help.go
Dan Anglin 8b03ba7be1
refactor: move command funcs to internal package
Move the command functions to the new internal commands package
2024-09-21 16:53:11 +01:00

29 lines
426 B
Go

package commands
import (
"fmt"
"maps"
"slices"
)
func HelpFunc(summaries map[string]string) CommandFunc {
return func(_ []string) error {
keys := []string{}
for key := range maps.All(summaries) {
keys = append(keys, key)
}
slices.Sort(keys)
fmt.Printf("\nCommands:\n")
for _, key := range slices.All(keys) {
fmt.Printf("\n%s: %s", key, summaries[key])
}
fmt.Printf("\n\n")
return nil
}
}