app

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package app common objects

Package app common objects

Package app handles informational requests

Package app can insert

Package app can get stats

Package app can remove an entry

Package app can show/clip an entry

Package app handles TOTP tokens.

Index

Constants

View Source
const (

	// TOTPCommand is the parent of totp and by defaults generates a rotating token
	TOTPCommand = "totp"
	// ConvCommand handles text conversion of the data store
	ConvCommand = "conv"
	// ClearCommand is a callback to manage clipboard clearing
	ClearCommand = "clear"
	// ClipCommand will copy values to the clipboard
	ClipCommand = "clip"
	// FindCommand is for simplistic searching of entries
	FindCommand = "find"
	// InsertCommand adds a value
	InsertCommand = "insert"
	// ListCommand lists all entries
	ListCommand = "ls"
	// MoveCommand will move source to destination
	MoveCommand = "mv"
	// ShowCommand will show the value in an entry
	ShowCommand = "show"
	// VersionCommand displays version information
	VersionCommand = "version"
	// HelpCommand shows usage
	HelpCommand = "help"
	// HelpAdvancedCommand shows advanced help
	HelpAdvancedCommand = "verbose"
	// RemoveCommand removes an entry
	RemoveCommand = "rm"
	// EnvCommand shows environment information used by lockbox
	EnvCommand = "env"
	// TOTPClipCommand is the argument for copying totp codes to clipboard
	TOTPClipCommand = ClipCommand
	// TOTPMinimalCommand is the argument for getting the short version of a code
	TOTPMinimalCommand = "minimal"
	// TOTPListCommand will list the totp-enabled entries
	TOTPListCommand = ListCommand
	// TOTPOnceCommand will perform like a normal totp request but not refresh
	TOTPOnceCommand = "once"
	// BashCommand is the command to generate bash completions
	BashCommand = "bash"
	// CompletionHelpCommand outputs completion help information
	CompletionHelpCommand = "help"
	// ReKeyCommand will rekey the underlying database
	ReKeyCommand = "rekey"
	// MultiLineCommand handles multi-line inserts (when not piped)
	MultiLineCommand = "multiline"
	// TOTPShowCommand is for showing the TOTP token
	TOTPShowCommand = ShowCommand
	// TOTPInsertCommand is for inserting totp tokens
	TOTPInsertCommand = InsertCommand
	// JSONCommand handles JSON outputs
	JSONCommand = "json"
	// ZshCommand is the command to generate zsh completions
	ZshCommand = "zsh"
)

Variables

View Source
var (
	// ErrNoTOTP is used when TOTP is requested BUT is disabled
	ErrNoTOTP = errors.New("totp is disabled")
	// ErrUnknownTOTPMode indicates an unknown totp argument type
	ErrUnknownTOTPMode = errors.New("unknown totp mode")
)

Functions

func Conv added in v1.1.0

func Conv(cmd CommandOptions) error

Conv will convert 1-N files

func Die added in v1.1.0

func Die(msg string)

Die will print a message and exit (non-zero)

func GenerateCompletions added in v1.1.0

func GenerateCompletions(isBash, isHelp bool, exe string) ([]string, error)

GenerateCompletions handles creating shell completion outputs

func Info

func Info(w io.Writer, command string, args []string) (bool, error)

Info will report help/bash/env details

func Insert added in v1.1.0

func Insert(cmd InsertOptions, mode InsertMode) error

Insert will execute an insert

func JSON added in v1.1.0

func JSON(cmd CommandOptions) error

JSON will get entries (1 or ALL) in JSON format

func List added in v1.1.0

func List(cmd CommandOptions) error

List will list/find entries

func Move

func Move(cmd CommandOptions) error

Move is the CLI command to move entries

func ReKey added in v1.1.0

func ReKey(cmd CommandOptions, r Keyer) error

ReKey handles entry rekeying

func Remove

func Remove(cmd CommandOptions) error

Remove will remove an entry

func ShowClip

func ShowClip(cmd CommandOptions, isShow bool) error

ShowClip will handle showing/clipping an entry

func Usage added in v1.1.0

func Usage(verbose bool, exe string) ([]string, error)

Usage return usage information

Types

type CommandOptions

type CommandOptions interface {
	Confirm(string) bool
	Args() []string
	Transaction() *backend.Transaction
	Writer() io.Writer
}

CommandOptions define how commands operate as an application

type Completions added in v1.1.0

type Completions struct {
	InsertCommand       string
	TOTPListCommand     string
	RemoveCommand       string
	ClipCommand         string
	ShowCommand         string
	MultiLineCommand    string
	MoveCommand         string
	TOTPCommand         string
	DoTOTPList          string
	DoList              string
	Executable          string
	JSONCommand         string
	HelpCommand         string
	HelpAdvancedCommand string
	Profiles            []Profile
	DefaultProfile      Profile
	Shell               string
	CompletionEnv       string
}

Completions handles the inputs to completions for templating

type DefaultCommand

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

DefaultCommand is the default CLI app type for actual execution

func NewDefaultCommand

func NewDefaultCommand(args []string) (*DefaultCommand, error)

NewDefaultCommand creates a new app command

func (*DefaultCommand) Args

func (a *DefaultCommand) Args() []string

Args will get the args passed to the application

func (*DefaultCommand) Confirm

func (a *DefaultCommand) Confirm(prompt string) bool

Confirm will confirm with the user (dying if something abnormal happens)

func (*DefaultCommand) Input

func (a *DefaultCommand) Input(pipe, multi bool) ([]byte, error)

Input will read user input

func (*DefaultCommand) IsPipe

func (a *DefaultCommand) IsPipe() bool

IsPipe will indicate if we're receiving pipe input

func (*DefaultCommand) SetArgs added in v1.1.0

func (a *DefaultCommand) SetArgs(args ...string)

SetArgs allow updating the command args

func (*DefaultCommand) Transaction

func (a *DefaultCommand) Transaction() *backend.Transaction

Transaction will return the backend transaction

func (*DefaultCommand) Writer

func (a *DefaultCommand) Writer() io.Writer

Writer will get stdout

type DefaultKeyer added in v1.1.0

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

DefaultKeyer is the default keyer for the application

func NewDefaultKeyer added in v1.1.0

func NewDefaultKeyer() (DefaultKeyer, error)

NewDefaultKeyer initializes the default keyer

func (DefaultKeyer) Insert added in v1.1.0

func (r DefaultKeyer) Insert(entry ReKeyEntry) error

Insert will insert the rekeying entry

func (DefaultKeyer) JSON added in v1.1.0

func (r DefaultKeyer) JSON() (map[string]backend.JSON, error)

JSON will get the JSON backing entries

type Documentation added in v1.1.0

type Documentation struct {
	Executable       string
	MoveCommand      string
	RemoveCommand    string
	ReKeyCommand     string
	ShellHelpCommand string
	ReKey            struct {
		Store   string
		KeyFile string
		Key     string
		KeyMode string
	}
}

Documentation is how documentation segments are templated

type InsertMode added in v1.1.0

type InsertMode uint

InsertMode changes how inserts are handled

const (
	// SingleLineInsert is a single line entry
	SingleLineInsert InsertMode = iota
	// MultiLineInsert is a multiline insert
	MultiLineInsert
	// TOTPInsert is a singleline but from TOTP subcommands
	TOTPInsert
)

type InsertOptions

type InsertOptions interface {
	CommandOptions
	IsPipe() bool
	Input(bool, bool) ([]byte, error)
}

InsertOptions are functions required for insert

type Keyer added in v1.1.0

type Keyer interface {
	JSON() (map[string]backend.JSON, error)
	Insert(ReKeyEntry) error
}

Keyer defines how rekeying happens

type Mode added in v1.1.0

type Mode int

Mode is the operating mode for TOTP operations

const (
	// UnknownTOTPMode is an unknown command
	UnknownTOTPMode Mode = iota
	// InsertTOTPMode is inserting a new totp token
	InsertTOTPMode
	// ShowTOTPMode will show the token
	ShowTOTPMode
	// ClipTOTPMode will copy to clipboard
	ClipTOTPMode
	// MinimalTOTPMode will display minimal information to display the token
	MinimalTOTPMode
	// ListTOTPMode lists the available tokens
	ListTOTPMode
	// OnceTOTPMode will only show the token once and exit
	OnceTOTPMode
)

type Profile added in v1.1.0

type Profile struct {
	Name      string
	CanClip   bool
	CanTOTP   bool
	CanList   bool
	ReadOnly  bool
	IsDefault bool
	// contains filtered or unexported fields
}

Profile is a completion profile

func (Profile) Display added in v1.1.0

func (p Profile) Display() string

Display is the profile display name

func (Profile) Env added in v1.1.0

func (p Profile) Env() string

Env will get the environment settable value to use this profile

func (Profile) Options added in v1.1.0

func (p Profile) Options() []string

Options will list the profile options

func (Profile) TOTPSubCommands added in v1.1.0

func (p Profile) TOTPSubCommands() []string

TOTPSubCommands are the list of sub commands for TOTP within the profile

type ReKeyEntry added in v1.1.0

type ReKeyEntry struct {
	Path string
	Env  []string
	Data []byte
}

ReKeyEntry is an entry that is being rekeyed

type TOTPArguments added in v1.1.0

type TOTPArguments struct {
	Mode  Mode
	Entry string
	// contains filtered or unexported fields
}

TOTPArguments are the parsed TOTP call arguments

func NewTOTPArguments added in v1.1.0

func NewTOTPArguments(args []string, tokenType string) (*TOTPArguments, error)

NewTOTPArguments will parse the input arguments

func (*TOTPArguments) Do added in v1.1.0

func (args *TOTPArguments) Do(opts TOTPOptions) error

Do will perform the TOTP operation

type TOTPOptions added in v1.1.0

type TOTPOptions struct {
	Clear         func()
	IsNoTOTP      func() (bool, error)
	IsInteractive func() (bool, error)
	// contains filtered or unexported fields
}

TOTPOptions are TOTP call options

func NewDefaultTOTPOptions added in v1.1.0

func NewDefaultTOTPOptions(app CommandOptions) TOTPOptions

NewDefaultTOTPOptions gets the default option set

Jump to

Keyboard shortcuts

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