app

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package app can do various conversions

Package app common objects

Package app handles informational requests

Package app can insert

Package app can get stats

Package app can list entries

Package app can move entries

Package app can generate passwords

Package app handles rekeying a database

Package app can remove an entry

Package app can show/clip an entry

Package app handles TOTP tokens.

Index

Constants

This section is empty.

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

func Conv(cmd CommandOptions) error

Conv will convert 1-N files

func Die

func Die(msg string)

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

func GeneratePassword added in v1.3.1

func GeneratePassword(cmd CommandOptions) error

GeneratePassword generates a password

func Info

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

Info will report help/bash/env details

func Insert

func Insert(cmd UserInputOptions, mode InsertMode) error

Insert will execute an insert

func JSON

func JSON(cmd CommandOptions) error

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

func List

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

func ReKey(cmd UserInputOptions) 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

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 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(interactive 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) Password added in v1.3.0

func (a DefaultCommand) Password() (string, error)

Password is how a keyer gets the user's password for rekey

func (DefaultCommand) ReadLine added in v1.3.0

func (a DefaultCommand) ReadLine() (string, error)

ReadLine handles a single stdin read

func (*DefaultCommand) SetArgs

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 InsertMode

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 Mode

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 TOTPArguments

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

TOTPArguments are the parsed TOTP call arguments

func NewTOTPArguments

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

NewTOTPArguments will parse the input arguments

func (*TOTPArguments) Do

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

Do will perform the TOTP operation

type TOTPOptions

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

TOTPOptions are TOTP call options

func NewDefaultTOTPOptions

func NewDefaultTOTPOptions(app CommandOptions) TOTPOptions

NewDefaultTOTPOptions gets the default option set

type UserInputOptions added in v1.3.0

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

UserInputOptions handle user inputs (e.g. password entry)

Directories

Path Synopsis
Package commands defines available commands within the app
Package commands defines available commands within the app
Package completions generations shell completions
Package completions generations shell completions
Package help manages usage information
Package help manages usage information

Jump to

Keyboard shortcuts

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