mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-19 19:17:02 -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
|
|
@ -15,6 +15,10 @@ type Model struct {
|
|||
Table table.Model
|
||||
}
|
||||
|
||||
func NewModel() Model {
|
||||
return Model{}
|
||||
}
|
||||
|
||||
func (m Model) Init() tea.Cmd { return nil }
|
||||
|
||||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
|
@ -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