1 Commits

Author SHA1 Message Date
7fc3bc7890 fix: table format rendering 2025-07-24 21:23:48 +02:00
3 changed files with 17 additions and 14 deletions

View File

@ -1,6 +1,3 @@
# unifood # unifood
University restaurant CLI that allows to retrieve menu information University restaurant CLI that allows to retrieve menu information
## Demo
![Demonstration video](docs/res/demo.mp4)

View File

@ -41,7 +41,6 @@ func (f *TableFormatter) Format(list *interfaces.ResourceList) (io.Reader, error
// Setup table // Setup table
t := table.NewWriter() t := table.NewWriter()
t.SetOutputMirror(outputBuffer)
t.SetStyle(table.StyleLight) t.SetStyle(table.StyleLight)
// Write header // Write header
@ -66,15 +65,22 @@ func (f *TableFormatter) Format(list *interfaces.ResourceList) (io.Reader, error
} }
// Render // Render
output := func() string {
switch f.RenderFormat { switch f.RenderFormat {
case tableFormatCSV: case tableFormatCSV:
t.RenderCSV() return t.RenderCSV()
case tableFormatHTML: case tableFormatHTML:
t.RenderHTML() return t.RenderHTML()
case tableFormatMarkdown: case tableFormatMarkdown:
t.RenderMarkdown() return t.RenderMarkdown()
default: default:
t.Render() return t.Render()
}
}()
_, err := outputBuffer.WriteString(output)
if err != nil {
return nil, fmt.Errorf("failed to write rendered table: %w", err)
} }
return outputBuffer, nil return outputBuffer, nil

Binary file not shown.