Compare commits
1 Commits
fix/table-
...
feat/demo
| Author | SHA1 | Date | |
|---|---|---|---|
| 92be4f65b0 |
@ -1,3 +1,6 @@
|
|||||||
# unifood
|
# unifood
|
||||||
|
|
||||||
University restaurant CLI that allows to retrieve menu information
|
University restaurant CLI that allows to retrieve menu information
|
||||||
|
|
||||||
|
## Demo
|
||||||
|

|
||||||
@ -41,6 +41,7 @@ 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
|
||||||
@ -65,22 +66,15 @@ 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:
|
||||||
return t.RenderCSV()
|
t.RenderCSV()
|
||||||
case tableFormatHTML:
|
case tableFormatHTML:
|
||||||
return t.RenderHTML()
|
t.RenderHTML()
|
||||||
case tableFormatMarkdown:
|
case tableFormatMarkdown:
|
||||||
return t.RenderMarkdown()
|
t.RenderMarkdown()
|
||||||
default:
|
default:
|
||||||
return t.Render()
|
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
|
||||||
|
|||||||
BIN
docs/res/demo.mp4
Normal file
BIN
docs/res/demo.mp4
Normal file
Binary file not shown.
Reference in New Issue
Block a user