feat: add table heading colors (#1321)

Signed-off-by: DRAGON <anantvijay3@gmail.com>
This commit is contained in:
DRAGON2002
2023-08-10 21:44:38 +05:30
committed by GitHub
parent 1d64522607
commit 9afae713ba
5 changed files with 35 additions and 0 deletions

View File

@@ -100,6 +100,13 @@ func prettyPrintListFormat(ctx context.Context, targetPolicy string, policies []
data := v2.Matrix{}
controlRows := generatePolicyRows(policies)
var headerColors []tablewriter.Colors
for range controlRows[0] {
headerColors = append(headerColors, tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiYellowColor})
}
policyTable.SetHeaderColor(headerColors...)
data = append(data, controlRows...)
policyTable.AppendBulk(data)
@@ -130,6 +137,11 @@ func prettyPrintControls(ctx context.Context, policies []string) {
} else {
controlsTable.SetHeader([]string{"Control ID", "Control Name", "Docs", "Frameworks"})
}
var headerColors []tablewriter.Colors
for range controlRows[0] {
headerColors = append(headerColors, tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiYellowColor})
}
controlsTable.SetHeaderColor(headerColors...)
data := v2.Matrix{}
data = append(data, controlRows...)

View File

@@ -97,6 +97,11 @@ func getCategoryTableWriter(writer io.Writer, headers []string, columnAligments
table.SetColumnAlignment(columnAligments)
table.SetAutoWrapText(false)
table.SetUnicodeHV(tablewriter.Regular, tablewriter.Regular)
var headerColors []tablewriter.Colors
for range headers {
headerColors = append(headerColors, tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiYellowColor})
}
table.SetHeaderColor(headerColors...)
return table
}

View File

@@ -70,6 +70,12 @@ func (fp *FrameworkPrinter) PrintSummaryTable(writer io.Writer, summaryDetails *
summaryTable.SetHeader(GetControlTableHeaders(short))
summaryTable.SetFooter(GenerateFooter(summaryDetails, short))
var headerColors []tablewriter.Colors
for range dataRows[0] {
headerColors = append(headerColors, tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiYellowColor})
}
summaryTable.SetHeaderColor(headerColors...)
summaryTable.AppendBulk(dataRows)
summaryTable.Render()

View File

@@ -19,6 +19,12 @@ func renderTable(writer io.Writer, headers []string, columnAlignments []int, row
table.SetColumnAlignment(columnAlignments)
table.SetUnicodeHV(tablewriter.Regular, tablewriter.Regular)
var headerColors []tablewriter.Colors
for range rows[0] {
headerColors = append(headerColors, tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiYellowColor})
}
table.SetHeaderColor(headerColors...)
table.AppendBulk(rows)
table.Render()

View File

@@ -65,6 +65,12 @@ func (prettyPrinter *PrettyPrinter) resourceTable(opaSessionObj *cautils.OPASess
}
summaryTable.SetHeader(generateResourceHeader(short))
var headerColors []tablewriter.Colors
for range resourceRows[0] {
headerColors = append(headerColors, tablewriter.Colors{tablewriter.Bold, tablewriter.FgHiYellowColor})
}
summaryTable.SetHeaderColor(headerColors...)
data := Matrix{}
data = append(data, resourceRows...)
// For control scan framework will be nil