lockbox

password manager
Log | Files | Refs | README | LICENSE

commit ed8fee4185d2ff37775b0e4ea5b9aa20b5ff54b6
parent 738a63269c55a9204a20e7125a3e9dc5dcbf35a7
Author: Sean Enck <sean@ttypty.com>
Date:   Sun,  3 Sep 2023 20:15:46 -0400

use subcategory

Diffstat:
Minternal/config/core.go | 7++++++-
Minternal/config/vars.go | 22++++++++++++++--------
2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/internal/config/core.go b/internal/config/core.go @@ -41,6 +41,9 @@ const ( ReKeyKeyFlag = "key" // ReKeyKeyModeFlag is the flag used for rekey to set the key mode ReKeyKeyModeFlag = "keymode" + // sub categories + clipCategory keyCategory = "CLIP_" + totpCategory keyCategory = "TOTP_" ) var ( @@ -49,12 +52,14 @@ var ( ) type ( + keyCategory string // JSONOutputMode is the output mode definition JSONOutputMode string // SystemPlatform represents the platform lockbox is running on. SystemPlatform string environmentBase struct { subKey string + cat keyCategory desc string requirement string whenUnset string @@ -126,7 +131,7 @@ func environOrDefault(envKey, defaultValue string) string { } func (e environmentBase) key() string { - return fmt.Sprintf("LOCKBOX_%s", e.subKey) + return fmt.Sprintf("LOCKBOX_%s%s", string(e.cat), e.subKey) } // Get will get the boolean value for the setting diff --git a/internal/config/vars.go b/internal/config/vars.go @@ -11,7 +11,6 @@ import ( ) const ( - clipBaseEnv = "CLIP_" commandArgsExample = "[cmd args...]" fileExample = "<file>" detectedValue = "<detected>" @@ -41,7 +40,8 @@ var ( // EnvClipMax gets the maximum clipboard time EnvClipMax = EnvironmentInt{ environmentBase: environmentBase{ - subKey: clipBaseEnv + "MAX", + subKey: "MAX", + cat: clipCategory, desc: "Override the amount of time before totp clears the clipboard (seconds).", }, shortDesc: "clipboard max time", allowZero: false, defaultValue: 45, @@ -56,7 +56,8 @@ var ( } // EnvClipOSC52 indicates if OSC52 clipboard mode is enabled EnvClipOSC52 = EnvironmentBool{environmentBase: environmentBase{ - subKey: clipBaseEnv + "OSC52", + subKey: "OSC52", + cat: clipCategory, desc: "Enable OSC52 clipboard mode.", }, defaultValue: false} // EnvNoTOTP indicates if TOTP is disabled @@ -92,7 +93,8 @@ var ( }, defaultValue: true} // EnvMaxTOTP is the max TOTP time to run (default) EnvMaxTOTP = EnvironmentInt{environmentBase: environmentBase{ - subKey: EnvTOTPToken.subKey + "_MAX", + subKey: "MAX", + cat: totpCategory, desc: "Time, in seconds, in which to show a TOTP token before automatically exiting.", }, shortDesc: "max totp time", allowZero: false, defaultValue: 120} // EnvTOTPToken is the leaf token to use to store TOTP tokens @@ -117,17 +119,20 @@ var ( }, allowed: []string{"<directory>"}, canDefault: true, defaultValue: ""} // EnvClipCopy allows overriding the clipboard copy command EnvClipCopy = EnvironmentCommand{environmentBase: environmentBase{ - subKey: clipBaseEnv + "COPY", + subKey: "COPY", + cat: clipCategory, desc: "Override the detected platform copy command.", }} // EnvClipPaste allows overriding the clipboard paste command EnvClipPaste = EnvironmentCommand{environmentBase: environmentBase{ - subKey: clipBaseEnv + "PASTE", + subKey: "PASTE", + cat: clipCategory, desc: "Override the detected platform paste command.", }} // EnvTOTPColorBetween handles terminal coloring for TOTP windows (seconds) EnvTOTPColorBetween = EnvironmentString{environmentBase: environmentBase{ - subKey: EnvTOTPToken.subKey + "_BETWEEN", + subKey: "BETWEEN", + cat: totpCategory, desc: fmt.Sprintf(`Override when to set totp generated outputs to different colors, must be a list of one (or more) rules where a '%s' delimits the start and end second (0-60 for each), and '%s' allows for multiple windows.`, colorWindowSpan, colorWindowDelimiter), @@ -152,7 +157,8 @@ and '%s' allows for multiple windows.`, colorWindowSpan, colorWindowDelimiter), } // EnvFormatTOTP supports formatting the TOTP tokens for generation of tokens EnvFormatTOTP = EnvironmentFormatter{environmentBase: environmentBase{ - subKey: EnvTOTPToken.subKey + "_FORMAT", + subKey: "FORMAT", + cat: totpCategory, desc: "Override the otpauth url used to store totp tokens. It must have ONE format string ('%s') to insert the totp base code.", }, fxn: formatterTOTP, allowed: "otpauth//url/%s/args..."} // EnvConfig is the location of the config file to read environment variables from