From b4259fcd7933ee4423f98fe508c023dd4bcf2273 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Tue, 25 Jan 2022 22:11:15 +0000 Subject: [PATCH] Add helper function for colouring expiries --- cmd/headscale/cli/pterm_style.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cmd/headscale/cli/pterm_style.go diff --git a/cmd/headscale/cli/pterm_style.go b/cmd/headscale/cli/pterm_style.go new file mode 100644 index 0000000..e267818 --- /dev/null +++ b/cmd/headscale/cli/pterm_style.go @@ -0,0 +1,20 @@ +package cli + +import ( + "time" + + "github.com/pterm/pterm" +) + +func ColourTime(date time.Time) string { + dateStr := date.Format("2006-01-02 15:04:05") + now := time.Now() + + if date.After(now) { + dateStr = pterm.LightGreen(dateStr) + } else { + dateStr = pterm.LightRed(dateStr) + } + + return dateStr +}