WIP: vertical render
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

See toolshed/organising#658
This commit is contained in:
decentral1se 2024-12-27 22:34:10 +01:00
parent 4e8995cc0e
commit a1fb0d281d
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
2 changed files with 34 additions and 7 deletions

View File

@ -20,7 +20,8 @@ var borderStyle = lipgloss.NewStyle().
var headerStyle = lipgloss.NewStyle().
Underline(true).
Bold(true)
Bold(true).
PaddingBottom(1)
var leftStyle = lipgloss.NewStyle().
Bold(true)
@ -51,6 +52,11 @@ func NewVersionOverview(
server = "local"
}
domain := app.Domain
if domain == "" {
domain = "N/A"
}
body := strings.Builder{}
body.WriteString(
borderStyle.Render(
@ -60,7 +66,7 @@ func NewVersionOverview(
lipgloss.JoinVertical(
lipgloss.Left,
horizontal(leftStyle.Render("SERVER"), " ", rightStyle.Render(server)),
horizontal(leftStyle.Render("DOMAIN"), " ", rightStyle.Render(app.Domain)),
horizontal(leftStyle.Render("DOMAIN"), " ", rightStyle.Render(domain)),
horizontal(leftStyle.Render("RECIPE"), " ", rightStyle.Render(app.Recipe.Name)),
horizontal(leftStyle.Render("CONFIG"), " ", rightStyle.Render(deployConfig)),
horizontal(leftStyle.Render("VERSION"), " ", rightStyle.Render(currentVersion)),
@ -112,6 +118,11 @@ func DeployOverview(app appPkg.App, warnMessages []string, version, chaosVersion
server = "local"
}
domain := app.Domain
if domain == "" {
domain = "N/A"
}
body := strings.Builder{}
body.WriteString(
borderStyle.Render(
@ -121,7 +132,7 @@ func DeployOverview(app appPkg.App, warnMessages []string, version, chaosVersion
lipgloss.JoinVertical(
lipgloss.Left,
horizontal(leftStyle.Render("SERVER"), " ", rightStyle.Render(server)),
horizontal(leftStyle.Render("DOMAIN"), " ", rightStyle.Render(app.Domain)),
horizontal(leftStyle.Render("DOMAIN"), " ", rightStyle.Render(domain)),
horizontal(leftStyle.Render("RECIPE"), " ", rightStyle.Render(app.Recipe.Name)),
horizontal(leftStyle.Render("CONFIG"), " ", rightStyle.Render(deployConfig)),
horizontal(leftStyle.Render("VERSION"), " ", rightStyle.Render(version)),

View File

@ -43,12 +43,28 @@ func HumanDuration(timestamp int64) string {
// CreateTable prepares a table layout for output.
func CreateTable() (*table.Table, error) {
var (
renderer = lipgloss.NewRenderer(os.Stdout)
headerStyle = renderer.NewStyle().Bold(true).Align(lipgloss.Center)
cellStyle = renderer.NewStyle().Padding(0, 1)
borderStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("63"))
)
table := table.New().
Border(lipgloss.ThickBorder()).
BorderStyle(
lipgloss.NewStyle().
Foreground(lipgloss.Color("63")),
)
BorderStyle(borderStyle).
StyleFunc(func(row, col int) lipgloss.Style {
var style lipgloss.Style
switch {
case row == table.HeaderRow:
return headerStyle
default:
style = cellStyle
}
return style
})
if isAbraCI, ok := os.LookupEnv("ABRA_CI"); ok && isAbraCI == "1" {
// NOTE(d1): no width limits for CI testing since we test against outputs