config

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package config handles user inputs/UI elements.

Package config handles user inputs/UI elements.

Package config handles user inputs/UI elements.

Index

Constants

View Source
const (

	// MacOSPlatform is the macos indicator for platform
	MacOSPlatform = "macos"
	// LinuxWaylandPlatform for linux+wayland
	LinuxWaylandPlatform = "linux-wayland"
	// LinuxXPlatform for linux+X
	LinuxXPlatform = "linux-x"
	// WindowsLinuxPlatform for WSL subsystems
	WindowsLinuxPlatform = "wsl"

	// ReKeyStoreFlag is the flag used for rekey to set the store
	ReKeyStoreFlag = "store"
	// ReKeyKeyFileFlag is the flag used for rekey to set the keyfile
	ReKeyKeyFileFlag = "keyfile"
	// ReKeyKeyFlag is the flag used for rekey to set the key
	ReKeyKeyFlag = "key"
	// ReKeyKeyModeFlag is the flag used for rekey to set the key mode
	ReKeyKeyModeFlag = "keymode"

	// YesValue are yes (on) values
	YesValue = yes
)

Variables

View Source
var (

	// Platforms represent the platforms that lockbox understands to run on
	Platforms = []string{MacOSPlatform, WindowsLinuxPlatform, LinuxXPlatform, LinuxWaylandPlatform}
	// TOTPDefaultColorWindow is the default coloring rules for totp
	TOTPDefaultColorWindow = []ColorWindow{{Start: 0, End: 5}, {Start: 30, End: 35}}
	// TOTPDefaultBetween is the default color window as a string
	TOTPDefaultBetween = toString(TOTPDefaultColorWindow)
	// EnvClipMax gets the maximum clipboard time
	EnvClipMax = EnvironmentInt{
				// contains filtered or unexported fields
	}
	// EnvHashLength handles the hashing output length
	EnvHashLength = EnvironmentInt{
					// contains filtered or unexported fields
	}
	// EnvClipOSC52 indicates if OSC52 clipboard mode is enabled
	EnvClipOSC52 = EnvironmentBool{
					// contains filtered or unexported fields
	}
	// EnvNoTOTP indicates if TOTP is disabled
	EnvNoTOTP = EnvironmentBool{
				// contains filtered or unexported fields
	}
	// EnvReadOnly indicates if in read-only mode
	EnvReadOnly = EnvironmentBool{
				// contains filtered or unexported fields
	}
	// EnvNoClip indicates clipboard functionality is off
	EnvNoClip = EnvironmentBool{
				// contains filtered or unexported fields
	}
	// EnvDefaultCompletion disable completion detection
	EnvDefaultCompletion = EnvironmentBool{
							// contains filtered or unexported fields
	}
	// EnvDefaultCompletionKey is the key for default completion handling
	EnvDefaultCompletionKey = EnvDefaultCompletion.key()
	// EnvNoColor indicates if color outputs are disabled
	EnvNoColor = EnvironmentBool{
				// contains filtered or unexported fields
	}
	// EnvInteractive indicates if operating in interactive mode
	EnvInteractive = EnvironmentBool{
					// contains filtered or unexported fields
	}
	// EnvMaxTOTP is the max TOTP time to run (default)
	EnvMaxTOTP = EnvironmentInt{
				// contains filtered or unexported fields
	}
	// EnvTOTPToken is the leaf token to use to store TOTP tokens
	EnvTOTPToken = EnvironmentString{
					// contains filtered or unexported fields
	}
	// EnvPlatform is the platform that the application is running on
	EnvPlatform = EnvironmentString{
				// contains filtered or unexported fields
	}
	// EnvStore is the location of the keepass file/store
	EnvStore = EnvironmentString{
				// contains filtered or unexported fields
	}
	// EnvHookDir is the directory of hooks to execute
	EnvHookDir = EnvironmentString{
				// contains filtered or unexported fields
	}
	// EnvClipCopy allows overriding the clipboard copy command
	EnvClipCopy = EnvironmentCommand{
				// contains filtered or unexported fields
	}
	// EnvClipPaste allows overriding the clipboard paste command
	EnvClipPaste = EnvironmentCommand{
					// contains filtered or unexported fields
	}
	// EnvTOTPColorBetween handles terminal coloring for TOTP windows (seconds)
	EnvTOTPColorBetween = EnvironmentString{
						// contains filtered or unexported fields
	}
	// EnvKeyFile is an keyfile for the database
	EnvKeyFile = EnvironmentString{
				// contains filtered or unexported fields
	}
	// EnvModTime is modtime override ability for entries
	EnvModTime = EnvironmentString{
				// contains filtered or unexported fields
	}
	// EnvJSONDataOutput controls how JSON is output in the 'data' field
	EnvJSONDataOutput = EnvironmentString{
						// contains filtered or unexported fields
	}
	// EnvFormatTOTP supports formatting the TOTP tokens for generation of tokens
	EnvFormatTOTP = EnvironmentFormatter{
					// contains filtered or unexported fields
	}
	// EnvConfig is the location of the config file to read environment variables from
	EnvConfig = EnvironmentString{
				// contains filtered or unexported fields
	}
)

Functions

func Environ

func Environ() []string

Environ will list the current environment keys

func ExpandParsed

func ExpandParsed(inputs map[string]string) (map[string]string, error)

ExpandParsed handles cycles of parsing configuration env inputs to resolve ALL variables

func GetReKey

func GetReKey(args []string) ([]string, error)

GetReKey will get the rekey environment settings

func IsUnset

func IsUnset(k, v string) (bool, error)

IsUnset will indicate if a variable is an unset (and unset it) or return that it isn't

func ListEnvironmentVariables

func ListEnvironmentVariables() []string

ListEnvironmentVariables will print information about env variables

func NewEnvFiles

func NewEnvFiles() ([]string, error)

NewEnvFiles will get the list of candidate environment files it will also set the environment to empty for the caller

func Wrap

func Wrap(indent uint, in string) string

Wrap performs simple block text word wrapping

Types

type AskPassword

type AskPassword func() (string, error)

AskPassword is a function to prompt for passwords (when required)

type ColorWindow

type ColorWindow struct {
	Start int
	End   int
}

ColorWindow for handling terminal colors based on timing

func ParseColorWindow

func ParseColorWindow(windowString string) ([]ColorWindow, error)

ParseColorWindow will handle parsing a window of colors for TOTP operations

type CompletionProfile

type CompletionProfile struct {
	Clip    bool
	TOTP    bool
	List    bool
	Write   bool
	Name    string
	Env     []string
	Default bool
}

CompletionProfile are shell completion definitions with backing environment information

func LoadCompletionProfiles

func LoadCompletionProfiles() []CompletionProfile

LoadCompletionProfiles will generate known completion profile with backing env information

type EnvironmentBool

type EnvironmentBool struct {
	// contains filtered or unexported fields
}

EnvironmentBool are environment settings that are booleans

func (EnvironmentBool) Get

func (e EnvironmentBool) Get() (bool, error)

Get will get the boolean value for the setting

func (EnvironmentBool) KeyValue

func (e EnvironmentBool) KeyValue(value string) string

KeyValue will get the string representation of the key+value

func (EnvironmentBool) Set

func (e EnvironmentBool) Set(value string) error

Setenv will do an environment set for the value to key

type EnvironmentCommand

type EnvironmentCommand struct {
	// contains filtered or unexported fields
}

EnvironmentCommand are settings that are parsed as shell commands

func (EnvironmentCommand) Get

func (e EnvironmentCommand) Get() ([]string, error)

Get will read (and shlex) the value if set

func (EnvironmentCommand) KeyValue

func (e EnvironmentCommand) KeyValue(value string) string

KeyValue will get the string representation of the key+value

func (EnvironmentCommand) Set

func (e EnvironmentCommand) Set(value string) error

Setenv will do an environment set for the value to key

type EnvironmentFormatter

type EnvironmentFormatter struct {
	// contains filtered or unexported fields
}

EnvironmentFormatter allows for sending a string into a get request

func (EnvironmentFormatter) Get

func (e EnvironmentFormatter) Get(value string) string

Get will retrieve the value with the formatted input included

func (EnvironmentFormatter) KeyValue

func (e EnvironmentFormatter) KeyValue(value string) string

KeyValue will get the string representation of the key+value

func (EnvironmentFormatter) Set

func (e EnvironmentFormatter) Set(value string) error

Setenv will do an environment set for the value to key

type EnvironmentInt

type EnvironmentInt struct {
	// contains filtered or unexported fields
}

EnvironmentInt are environment settings that are integers

func (EnvironmentInt) Get

func (e EnvironmentInt) Get() (int, error)

Get will get the integer value for the setting

func (EnvironmentInt) KeyValue

func (e EnvironmentInt) KeyValue(value string) string

KeyValue will get the string representation of the key+value

func (EnvironmentInt) Set

func (e EnvironmentInt) Set(value string) error

Setenv will do an environment set for the value to key

type EnvironmentString

type EnvironmentString struct {
	// contains filtered or unexported fields
}

EnvironmentString are string-based settings

func (EnvironmentString) Get

func (e EnvironmentString) Get() string

Get will read the string from the environment

func (EnvironmentString) KeyValue

func (e EnvironmentString) KeyValue(value string) string

KeyValue will get the string representation of the key+value

func (EnvironmentString) Set

func (e EnvironmentString) Set(value string) error

Setenv will do an environment set for the value to key

type JSONOutputMode

type JSONOutputMode string

JSONOutputMode is the output mode definition

const (

	// ModTimeFormat is the expected modtime format
	ModTimeFormat = time.RFC3339
	// JSONDataOutputHash means output data is hashed
	JSONDataOutputHash JSONOutputMode = "hash"
	// JSONDataOutputBlank means an empty entry is set
	JSONDataOutputBlank JSONOutputMode = "empty"
	// JSONDataOutputRaw means the RAW (unencrypted) value is displayed
	JSONDataOutputRaw JSONOutputMode = "plaintext"
)

func ParseJSONOutput

func ParseJSONOutput() (JSONOutputMode, error)

ParseJSONOutput handles detecting the JSON output mode

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is a wrapper to help manage the returned key

func NewKey

func NewKey(defaultKeyModeType KeyModeType) (Key, error)

NewKey will create a new key

func (Key) Ask

func (k Key) Ask() bool

Ask will indicate if prompting is required to get the key

func (Key) Read

func (k Key) Read(ask AskPassword) (string, error)

Read will read the key as configured by the mode

type KeyModeType

type KeyModeType string

KeyModeType are valid ways to get the key

const (

	// IgnoreKeyMode will ignore the value set in the key (acts like no key)
	IgnoreKeyMode KeyModeType = "ignore"

	// DefaultKeyMode is the default operating keymode if NOT set
	DefaultKeyMode = commandKeyMode
)

type SystemPlatform

type SystemPlatform string

SystemPlatform represents the platform lockbox is running on.

func NewPlatform

func NewPlatform() (SystemPlatform, error)

NewPlatform gets a new system platform.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL