From 42c4dbb3da50f3a4d4f687d6c34fe04b13e79c8a Mon Sep 17 00:00:00 2001 From: Shane C Date: Wed, 7 Aug 2024 14:36:32 -0400 Subject: [PATCH] add displaylist --- displaylist/displaylist.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 displaylist/displaylist.go diff --git a/displaylist/displaylist.go b/displaylist/displaylist.go new file mode 100644 index 0000000..7af6046 --- /dev/null +++ b/displaylist/displaylist.go @@ -0,0 +1,31 @@ +package displaylist + +import ( + "fmt" + + "git.eggactyl.cloud/Eggactyl/tui" +) + +type ListOptions struct { + Title string + Items []Item +} + +type Item struct { + Key string + Value string +} + +func New(opts ListOptions) { + + fmt.Println(tui.FgColorGrey + "[ " + tui.Format(tui.FgColorGold, tui.FmtUnderline) + opts.Title + tui.Format(tui.FmtUnderlineReset, tui.FgColorGrey) + " " + " ]" + tui.FmtReset) + + for _, item := range opts.Items { + fmt.Println(itemString(item.Key, item.Value)) + } + +} + +func itemString(key string, value string) string { + return tui.FgColorGrey + "[ " + tui.FgColorGold + key + " " + tui.FgColorGrey + value + tui.FgColorGrey + " ]" + tui.FmtReset +}