• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mindersec / minder / 15722237041

18 Jun 2025 02:09AM UTC coverage: 57.352%. First build
15722237041

Pull #5699

github

web-flow
Merge 2f121ebee into 2f07fd3f2
Pull Request #5699: Replace github.com/olekukonko/tablewriter with charmbracelet/lipgloss

0 of 54 new or added lines in 1 file covered. (0.0%)

18472 of 32208 relevant lines covered (57.35%)

37.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/internal/util/cli/table/table.go
1
// SPDX-FileCopyrightText: Copyright 2023 The Minder Authors
2
// SPDX-License-Identifier: Apache-2.0
3

4
// Package table contains utilities for rendering tables
5
package table
6

7
import (
8
        "fmt"
9
        "os"
10

11
        "github.com/charmbracelet/lipgloss"
12
        lg "github.com/charmbracelet/lipgloss/table"
13
        "golang.org/x/term"
14

15
        "github.com/mindersec/minder/internal/util/cli/table/layouts"
16
)
17

18
const (
19
        // Simple is a simple table
20
        Simple = "simple"
21
)
22

23
// Table is an interface for rendering tables
24
type Table interface {
25
        AddRow(row ...string)
26
        AddRowWithColor(row ...layouts.ColoredColumn)
27
        // Render outputs the table to stdout (TODO: make output configurable)
28
        Render()
29
        // SeparateRows ensures each row is clearly separated (probably because it is multi-line)
30
        SeparateRows()
31
}
32

33
// New creates a new table
NEW
34
func New(_ string, _ layouts.TableLayout, header []string) Table {
×
NEW
35
        w, _, err := term.GetSize(int(os.Stdout.Fd()))
×
NEW
36
        if err != nil || w == 0 {
×
NEW
37
                w = 80 // Default width if we can't determine terminal size
×
NEW
38
        }
×
NEW
39
        return &lipGlossTable{
×
NEW
40
                table: lg.New().
×
NEW
41
                        //Border(lipgloss.HiddenBorder()).
×
NEW
42
                        BorderTop(false).BorderBottom(false).
×
NEW
43
                        BorderLeft(false).BorderRight(false).
×
NEW
44
                        Headers(header...).
×
NEW
45
                        Width(w).Wrap(true),
×
NEW
46
                colors: make(map[int]map[int]layouts.Color),
×
NEW
47
        }
×
48
}
49

50
type lipGlossTable struct {
51
        table  *lg.Table
52
        rows   int
53
        colors map[int]map[int]layouts.Color
54
}
55

56
// AddRow implements Table.
NEW
57
func (l *lipGlossTable) AddRow(row ...string) {
×
NEW
58
        l.table.Row(row...)
×
NEW
59
        l.rows++
×
NEW
60
}
×
61

62
// AddRowWithColor implements Table.
NEW
63
func (l *lipGlossTable) AddRowWithColor(row ...layouts.ColoredColumn) {
×
NEW
64
        cells := make([]string, 0, len(row))
×
NEW
65
        for i, cell := range row {
×
NEW
66
                cells = append(cells, cell.Column)
×
NEW
67
                if cell.Color != "" {
×
NEW
68
                        row := l.colors[l.rows]
×
NEW
69
                        if row == nil {
×
NEW
70
                                row = make(map[int]layouts.Color)
×
NEW
71
                                l.colors[l.rows] = row
×
NEW
72
                        }
×
NEW
73
                        l.colors[l.rows][i] = cell.Color
×
74
                }
75
        }
NEW
76
        l.AddRow(cells...)
×
77
}
78

79
// SeparateRows implements Table.
NEW
80
func (l *lipGlossTable) SeparateRows() {
×
NEW
81
        l.table.BorderRow(true).
×
NEW
82
                BorderLeft(true).BorderRight(true).
×
NEW
83
                BorderTop(true).BorderBottom(true)
×
NEW
84
}
×
85

86
// Render implements Table.
NEW
87
func (l *lipGlossTable) Render() {
×
NEW
88
        l.table.StyleFunc(func(row, col int) lipgloss.Style {
×
NEW
89
                style := lipgloss.NewStyle().
×
NEW
90
                        Padding(0, 1)
×
NEW
91
                rowData := l.colors[row]
×
NEW
92
                if rowData == nil {
×
NEW
93
                        return style
×
NEW
94
                }
×
NEW
95
                color := rowData[col]
×
NEW
96
                switch color {
×
NEW
97
                case layouts.ColorRed:
×
NEW
98
                        return style.Foreground(lipgloss.Color("#ff0000"))
×
NEW
99
                case layouts.ColorGreen:
×
NEW
100
                        return style.Foreground(lipgloss.Color("#00ff00"))
×
NEW
101
                case layouts.ColorYellow:
×
NEW
102
                        return style.Foreground(lipgloss.Color("#ffff00"))
×
NEW
103
                default:
×
NEW
104
                        return style
×
105
                }
106
        })
107

NEW
108
        fmt.Println(l.table.Render())
×
109
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc