From 79c6a1ea8a211dc8f8f3acaaf398bdb34c8329d6 Mon Sep 17 00:00:00 2001 From: bdoerfchen Date: Thu, 24 Jul 2025 21:19:40 +0200 Subject: [PATCH] feat: add name formatter --- core/output/formatter.go | 1 + core/output/name.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 core/output/name.go diff --git a/core/output/formatter.go b/core/output/formatter.go index f5f0583..bacbd2b 100644 --- a/core/output/formatter.go +++ b/core/output/formatter.go @@ -12,4 +12,5 @@ var Formatters = map[string]interfaces.Formatter{ "csv": &TableFormatter{HideSummary: true, RenderFormat: tableFormatCSV}, "html": &TableFormatter{HideSummary: true, RenderFormat: tableFormatHTML}, "markdown": &TableFormatter{HideSummary: true, RenderFormat: tableFormatMarkdown}, + "name": &NameFormatter{}, } diff --git a/core/output/name.go b/core/output/name.go new file mode 100644 index 0000000..32ee4aa --- /dev/null +++ b/core/output/name.go @@ -0,0 +1,21 @@ +package output + +import ( + "bytes" + "io" + + "git.bissendorf.co/bissendorf/unifood/m/v2/core/interfaces" +) + +type NameFormatter struct{} + +func (f *NameFormatter) Format(list *interfaces.ResourceList) (io.Reader, error) { + var buffer = make([]byte, 0, 1024) + outputBuffer := bytes.NewBuffer(buffer) + + for _, item := range list.Items { + outputBuffer.WriteString(item.ItemName() + "\r\n") + } + + return outputBuffer, nil +}