From 6af2bce6a623ab2dd7eb6191bfb3accc403025cf Mon Sep 17 00:00:00 2001 From: David Barbion Date: Fri, 14 Mar 2025 15:19:47 +0100 Subject: [PATCH] feat: add ansi colors in table output --- writer/table.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/writer/table.go b/writer/table.go index 8179a90..54ef35a 100644 --- a/writer/table.go +++ b/writer/table.go @@ -15,6 +15,7 @@ type TableWriter struct { } var tableOrder = []string{"import", "add", "update", "recreate", "delete"} +var tableColor = map[string]string{"import": "\033[34;1m", "add": "\033[32;1m", "update": "\033[33;1m", "recreate": "\033[36;1m", "delete": "\033[31;1m"} func (t TableWriter) Write(writer io.Writer) error { tableString := make([][]string, 0, 4) @@ -24,7 +25,7 @@ func (t TableWriter) Write(writer io.Writer) error { if t.mdEnabled { tableString = append(tableString, []string{change, fmt.Sprintf("`%s`", changedResource.Address)}) } else { - tableString = append(tableString, []string{change, changedResource.Address}) + tableString = append(tableString, []string{tableColor[change] + change + "\033[0m", changedResource.Address}) } } }