-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use charmbracelet/lipgloss for tables and remove tablewriter (#136)
- Loading branch information
Showing
9 changed files
with
132 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/charmbracelet/lipgloss/table" | ||
) | ||
|
||
func newTable( | ||
format OutputFormat, | ||
override func(style lipgloss.Style, row, col int) lipgloss.Style, | ||
) *table.Table { | ||
tbl := table.New() | ||
switch format { | ||
case OutputFormatPlain: | ||
tbl.Border(lipgloss.HiddenBorder()).BorderTop(false).BorderBottom(false) | ||
case OutputFormatMarkdown: | ||
tbl.Border(markdownBorder).BorderBottom(false).BorderTop(false) | ||
case OutputFormatBasic: | ||
tbl.Border(lipgloss.RoundedBorder()) | ||
} | ||
return tbl.StyleFunc(func(row, col int) lipgloss.Style { | ||
// Default style, may be overridden. | ||
style := lipgloss.NewStyle().PaddingLeft(1).PaddingRight(1).Align(lipgloss.Center) | ||
if override != nil { | ||
style = override(style, row, col) | ||
} | ||
return style | ||
}) | ||
} | ||
|
||
var markdownBorder = lipgloss.Border{ | ||
Top: "-", | ||
Bottom: "-", | ||
Left: "|", | ||
Right: "|", | ||
TopLeft: "", // empty for markdown | ||
TopRight: "", // empty for markdown | ||
BottomLeft: "", // empty for markdown | ||
BottomRight: "", // empty for markdown | ||
MiddleLeft: "|", | ||
MiddleRight: "|", | ||
Middle: "|", | ||
MiddleTop: "|", | ||
MiddleBottom: "|", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.