commit 6ffc529e538c42cc2a33d6602c7a84ac8a1399b5
parent ac1bbdd92a8d5b1d29d70bff6150c4edfce87b3d
Author: Sean Enck <sean@ttypty.com>
Date: Wed, 12 Jan 2022 18:32:18 -0500
totp coloring changes
Diffstat:
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/cmd/lb-totp/main.go b/cmd/lb-totp/main.go
@@ -107,42 +107,38 @@ func display(token string, clip, once, short bool) error {
}
lastSecond = last
left := 60 - last
- expires := fmt.Sprintf("%s, expires: %2d (seconds)", now.Format("15:04:05"), left)
- outputs := []string{expires}
code, err := otp.GenerateCode(totpToken, now)
if err != nil {
return err
}
startColor := ""
endColor := ""
- if left < 10 {
+ if left < 5 || (left < 35 && left >= 30) {
startColor = redStart
endColor = redEnd
}
+ expires := fmt.Sprintf("%s%s, expires: %2d (seconds)%s", startColor, now.Format("15:04:05"), left, endColor)
+ outputs := []string{expires}
if !clip {
outputs = append(outputs, fmt.Sprintf("%s\n %s", tok, code))
if !once {
outputs = append(outputs, "-> CTRL+C to exit")
}
} else {
- colorize(startColor, fmt.Sprintf("\n -> %s\n", expires), endColor)
+ fmt.Printf("-> %s\n", expires)
internal.CopyToClipboard(code)
return nil
}
if !once {
clear()
}
- colorize(startColor, strings.Join(outputs, "\n\n"), endColor)
+ fmt.Printf("%s\n", strings.Join(outputs, "\n\n"))
if once {
return nil
}
}
}
-func colorize(start, text, end string) {
- fmt.Printf("%s%s%s\n", start, text, end)
-}
-
func main() {
args := os.Args
if len(args) > 3 || len(args) < 2 {