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

mindersec / minder / 15720057588

17 Jun 2025 11:19PM UTC coverage: 57.352%. First build
15720057588

Pull #5699

github

web-flow
Merge 730ba342d 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.33 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
        "github.com/mindersec/minder/internal/util/cli/table/layouts"
14
        "golang.org/x/term"
15
)
16

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

22
// Table is an interface for rendering tables
23
type Table interface {
24
        AddRow(row ...string)
25
        AddRowWithColor(row ...layouts.ColoredColumn)
26
        Render()
27
        SeparateRows()
28
}
29

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

47
type LipGlossTable struct {
48
        table  *lg.Table
49
        rows   int
50
        colors map[int]map[int]layouts.Color
51
}
52

53
// AddRow implements Table.
NEW
54
func (l *LipGlossTable) AddRow(row ...string) {
×
NEW
55
        l.table.Row(row...)
×
NEW
56
        l.rows++
×
NEW
57
}
×
58

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

76
// SeparateRows implements Table.
NEW
77
func (l *LipGlossTable) SeparateRows() {
×
NEW
78
        l.table.BorderRow(true).
×
NEW
79
                BorderLeft(true).BorderRight(true).
×
NEW
80
                BorderTop(true).BorderBottom(true)
×
NEW
81
}
×
82

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

NEW
105
        fmt.Println(l.table.Render())
×
106
}
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