mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
refactor: updated cache editor implementation
This commit is contained in:
parent
3bae20832f
commit
e85fd21922
6 changed files with 78 additions and 28 deletions
|
|
@ -3,6 +3,7 @@ package util
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
|
@ -23,3 +24,22 @@ func PrintYAML(data any) {
|
|||
}
|
||||
fmt.Print(string(b))
|
||||
}
|
||||
|
||||
func PrintMap(data map[string]any) {
|
||||
for k, v := range data {
|
||||
fmt.Printf("%s: %v\n", k, v)
|
||||
}
|
||||
}
|
||||
|
||||
func PrintMapWithFormat(data map[string]any, format string) {
|
||||
switch strings.ToLower(format) {
|
||||
case "json":
|
||||
PrintJSON(data)
|
||||
case "yaml":
|
||||
PrintYAML(data)
|
||||
case "list":
|
||||
PrintMap(data)
|
||||
default:
|
||||
log.Error().Msg("PrintMapWithFormat: unrecognized format")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue