commit a2d393ceee4db3649fced5db511c4b4745477199
parent 5cd50be526cc8f0f3b7a4943d92c68c902bb1811
Author: Sean Enck <sean@ttypty.com>
Date: Tue, 11 Oct 2022 20:07:41 -0400
default between indicator
Diffstat:
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/internal/inputs/env.go b/internal/inputs/env.go
@@ -54,6 +54,8 @@ const (
// WindowsLinuxPlatform for WSL subsystems
WindowsLinuxPlatform = "wsl"
defaultMaxClipboard = 45
+ // TOTPDefaultBetween handles colorized time bounds for TOTP display
+ TOTPDefaultBetween = "0:5,30:35"
)
var (
@@ -233,7 +235,7 @@ func ListEnvironmentVariables(args []string) error {
e.printEnvironmentVariable(false, readOnlyEnv, isNo, "operate in readonly mode", isYesNoArgs)
e.printEnvironmentVariable(false, fieldTOTPEnv, defaultTOTPField, "attribute name to store TOTP tokens within the database", []string{"string"})
e.printEnvironmentVariable(false, formatTOTPEnv, strings.ReplaceAll(FormatTOTP("%s"), "%25s", "%s"), "override the otpauth url used to store totp tokens (e.g. otpauth://totp/%s/rest/of/string), must have ONE format '%s' to insert the totp base code", []string{"otpauth//url/%s/args..."})
- e.printEnvironmentVariable(false, ColorBetweenEnv, "", "override when to set totp generated outputs to different colors (e.g. 0:5,30:35), must be a list of one (or more) rules where a semicolon delimits the start and end second (0-60 for each)", []string{"start:end,start:end,start:end..."})
+ e.printEnvironmentVariable(false, ColorBetweenEnv, TOTPDefaultBetween, "override when to set totp generated outputs to different colors (e.g. 0:5,30:35), must be a list of one (or more) rules where a semicolon delimits the start and end second (0-60 for each)", []string{"start:end,start:end,start:end..."})
e.printEnvironmentVariable(false, ClipPasteEnv, "", "override the detected platform paste command", []string{commandArgsExample})
e.printEnvironmentVariable(false, ClipPasteEnv, "", "override the detected platform copy command", []string{commandArgsExample})
e.printEnvironmentVariable(false, clipMaxEnv, fmt.Sprintf("%d", defaultMaxClipboard), "override the amount of time before totp clears the clipboard (e.g. 10), must be an integer", []string{"integer"})
diff --git a/internal/totp/core.go b/internal/totp/core.go
@@ -55,8 +55,8 @@ func clear() {
}
func colorWhenRules() ([]colorWhen, error) {
- envTime := os.Getenv(inputs.ColorBetweenEnv)
- if envTime == "" {
+ envTime := inputs.EnvOrDefault(inputs.ColorBetweenEnv, inputs.TOTPDefaultBetween)
+ if envTime == "" || envTime == inputs.TOTPDefaultBetween {
return []colorWhen{
{start: 0, end: 5},
{start: 30, end: 35},