Documentation
¶
Index ¶
- func Help(cmd Command) string
- func Usage(cmd Command) string
- type AddCommand
- func (cmd *AddCommand) GetArgs() interface{}
- func (cmd *AddCommand) GetName() string
- func (cmd *AddCommand) IsSane() bool
- func (cmd *AddCommand) Parse(args []string) error
- func (cmd *AddCommand) PrintUsage()
- func (cmd *AddCommand) Run() int
- func (cmd *AddCommand) SetSpinnerControl(pause, resume func())
- type AddCommandArgs
- type AppendCommand
- type AppendCommandArgs
- type AppendMode
- type CatCommand
- type CatCommandArgs
- type CdCommand
- type CdCommandArgs
- type Command
- type Commands
- type Confirmer
- type CopyCommand
- type CopyCommandArgs
- type GrepCommand
- func (cmd *GrepCommand) GetArgs() interface{}
- func (cmd *GrepCommand) GetName() string
- func (cmd *GrepCommand) GetSearchParams() SearchParameters
- func (cmd *GrepCommand) IsSane() bool
- func (cmd *GrepCommand) Parse(args []string) error
- func (cmd *GrepCommand) PrintUsage()
- func (cmd *GrepCommand) Run() int
- type GrepCommandArgs
- type KeyValueCommand
- type KeyValueMode
- type ListCommand
- type ListCommandArgs
- type Match
- type MatchOutput
- type MatchOutputArg
- type MoveCommand
- type MoveCommandArgs
- type RemoveCommand
- type RemoveCommandArgs
- type ReplaceCommand
- func (cmd *ReplaceCommand) FindReplacements(search string, replacement string, path string) (matches []*Match, err error)
- func (cmd *ReplaceCommand) GetArgs() interface{}
- func (cmd *ReplaceCommand) GetName() string
- func (cmd *ReplaceCommand) GetSearchParams() SearchParameters
- func (cmd *ReplaceCommand) IsSane() bool
- func (cmd *ReplaceCommand) Parse(args []string) error
- func (cmd *ReplaceCommand) PrintUsage()
- func (cmd *ReplaceCommand) Run() int
- func (cmd *ReplaceCommand) SetSpinnerControl(pause, resume func())
- func (cmd *ReplaceCommand) WriteReplacements(groupedMatches map[string][]*Match) error
- type ReplaceCommandArgs
- type SearchParameters
- type Searcher
- type SearchingCommand
- type SpinnerAware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddCommand ¶
type AddCommand struct {
// contains filtered or unexported fields
}
AddCommand container for all 'append' parameters
func NewAddCommand ¶
func NewAddCommand(c *client.Client) *AddCommand
NewAddCommand creates a new AddCommand parameter container
func (*AddCommand) GetArgs ¶
func (cmd *AddCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
func (*AddCommand) GetName ¶
func (cmd *AddCommand) GetName() string
GetName returns the AddCommand's name identifier
func (*AddCommand) IsSane ¶
func (cmd *AddCommand) IsSane() bool
IsSane returns true if command is sane
func (*AddCommand) Parse ¶
func (cmd *AddCommand) Parse(args []string) error
Parse parses the arguments into the Command and Args structs
func (*AddCommand) Run ¶
func (cmd *AddCommand) Run() int
Run executes 'add' with given AddCommand's parameters
func (*AddCommand) SetSpinnerControl ¶
func (cmd *AddCommand) SetSpinnerControl(pause, resume func())
SetSpinnerControl satisfies SpinnerAware so the spinner can be paused while askForConfirmation is reading stdin.
type AddCommandArgs ¶
type AddCommandArgs struct {
Key string `arg:"positional,required"`
Value string `arg:"positional,required"`
Path string `arg:"positional,required"`
Force bool `arg:"-f,--force" help:"Overwrite key if exists"`
Confirm bool `arg:"-y,--confirm" help:"Write results without prompt"`
DryRun bool `arg:"-n,--dry-run" help:"Skip writing results without prompt"`
}
AddCommandArgs provides a struct for go-arg parsing
func (AddCommandArgs) Description ¶
func (AddCommandArgs) Description() string
Description provides detail on what the command does
type AppendCommand ¶
type AppendCommand struct {
Mode AppendMode
// contains filtered or unexported fields
}
AppendCommand container for all 'append' parameters
func NewAppendCommand ¶
func NewAppendCommand(c *client.Client) *AppendCommand
NewAppendCommand creates a new AppendCommand parameter container
func (*AppendCommand) GetArgs ¶
func (cmd *AppendCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
func (*AppendCommand) GetName ¶
func (cmd *AppendCommand) GetName() string
GetName returns the AppendCommand's name identifier
func (*AppendCommand) IsSane ¶
func (cmd *AppendCommand) IsSane() bool
IsSane returns true if command is sane
func (*AppendCommand) Parse ¶
func (cmd *AppendCommand) Parse(args []string) error
Parse parses the arguments into the Command and Args structs
func (*AppendCommand) PrintUsage ¶
func (cmd *AppendCommand) PrintUsage()
PrintUsage print command usage
func (*AppendCommand) Run ¶
func (cmd *AppendCommand) Run() int
Run executes 'append' with given AppendCommand's parameters
type AppendCommandArgs ¶
type AppendCommandArgs struct {
Source string `arg:"positional,required"`
Target string `arg:"positional,required"`
Force bool `arg:"-f,--force" help:"Overwrite key if exists"`
Skip bool `arg:"-s,--skip" help:"Skip key if exists (default)"`
Rename bool `arg:"-r,--rename" help:"Rename key if exists"`
}
AppendCommandArgs provides a struct for go-arg parsing
func (AppendCommandArgs) Description ¶
func (AppendCommandArgs) Description() string
Description provides detail on what the command does
type AppendMode ¶
type AppendMode string
AppendMode defines behaviour in case existing secrets are in conflict
const ( // ModeSkip do not append secret on conflict ModeSkip AppendMode = "skip" // ModeOverwrite overwrite existing secret on conflict ModeOverwrite AppendMode = "overwrite" // ModeRename keep existing secret and create a new key on conflict ModeRename AppendMode = "rename" // ModeInvalid denotes invalid mode ModeInvalid AppendMode = "invalid" )
type CatCommand ¶
type CatCommand struct {
// contains filtered or unexported fields
}
CatCommand container for all 'cat' parameters
func NewCatCommand ¶
func NewCatCommand(c *client.Client) *CatCommand
NewCatCommand creates a new CatCommand parameter container
func (*CatCommand) GetArgs ¶
func (cmd *CatCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
func (*CatCommand) GetName ¶
func (cmd *CatCommand) GetName() string
GetName returns the CatCommand's name identifier
func (*CatCommand) IsSane ¶
func (cmd *CatCommand) IsSane() bool
IsSane returns true if command is sane
func (*CatCommand) Parse ¶
func (cmd *CatCommand) Parse(args []string) error
Parse given arguments and return status
func (*CatCommand) Run ¶
func (cmd *CatCommand) Run() int
Run executes 'cat' with given CatCommand's parameters
type CatCommandArgs ¶
type CatCommandArgs struct {
Path string `arg:"positional,required" help:"path to display contents"`
}
CatCommandArgs provides a struct for go-arg parsing
func (CatCommandArgs) Description ¶
func (CatCommandArgs) Description() string
Description provides detail on what the command does
type CdCommand ¶
type CdCommand struct {
// contains filtered or unexported fields
}
CdCommand container for all 'cd' parameters
func NewCdCommand ¶
NewCdCommand creates a new CdCommand parameter container
func (*CdCommand) GetArgs ¶
func (cmd *CdCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
type CdCommandArgs ¶
type CdCommandArgs struct {
Path string `arg:"positional,required" help:"change cwd to path"`
}
CdCommandArgs provides a struct for go-arg parsing
func (CdCommandArgs) Description ¶
func (CdCommandArgs) Description() string
Description provides detail on what the command does
type Command ¶
type Command interface {
Run() int
GetName() string
GetArgs() interface{}
IsSane() bool
PrintUsage()
Parse(args []string) error
}
Command interface to describe a command structure
type Commands ¶
type Commands struct {
Add *AddCommand
Append *AppendCommand
Cat *CatCommand
Cd *CdCommand
Cp *CopyCommand
Grep *GrepCommand
Ls *ListCommand
Mv *MoveCommand
Replace *ReplaceCommand
Rm *RemoveCommand
}
Commands contains all available commands
func NewCommands ¶
NewCommands returns a Commands struct with all available commands
type Confirmer ¶
type Confirmer interface {
Confirm() bool
}
Confirmer is implemented by commands that must prompt the user before running. Confirm() is called outside RunWithSpinner so the spinner never races with stdin.
type CopyCommand ¶
type CopyCommand struct {
// contains filtered or unexported fields
}
CopyCommand container for all 'cp' parameters
func NewCopyCommand ¶
func NewCopyCommand(c *client.Client, workerCount int) *CopyCommand
NewCopyCommand creates a new CopyCommand parameter container
func (*CopyCommand) GetArgs ¶
func (cmd *CopyCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
func (*CopyCommand) GetName ¶
func (cmd *CopyCommand) GetName() string
GetName returns the CopyCommand's name identifier
func (*CopyCommand) IsSane ¶
func (cmd *CopyCommand) IsSane() bool
IsSane returns true if command is sane
func (*CopyCommand) Parse ¶
func (cmd *CopyCommand) Parse(args []string) error
Parse given arguments and return status
func (*CopyCommand) PrintUsage ¶
func (cmd *CopyCommand) PrintUsage()
PrintUsage print command usage
func (*CopyCommand) Run ¶
func (cmd *CopyCommand) Run() int
Run executes 'cp' with given CopyCommand's parameters
type CopyCommandArgs ¶
type CopyCommandArgs struct {
Recursive bool `arg:"-r" help:"recursively copy a directory"`
Source string `arg:"positional,required" help:"path to copy from"`
Target string `arg:"positional,required" help:"path to copy to"`
}
CopyCommandArgs provides a struct for go-arg parsing
func (CopyCommandArgs) Description ¶
func (CopyCommandArgs) Description() string
Description provides detail on what the command does
type GrepCommand ¶
type GrepCommand struct {
Mode KeyValueMode
// contains filtered or unexported fields
}
GrepCommand container for all 'grep' parameters
func NewGrepCommand ¶
func NewGrepCommand(c *client.Client, workerCount int) *GrepCommand
NewGrepCommand creates a new GrepCommand parameter container
func (*GrepCommand) GetArgs ¶
func (cmd *GrepCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
func (*GrepCommand) GetName ¶
func (cmd *GrepCommand) GetName() string
GetName returns the GrepCommand's name identifier
func (*GrepCommand) GetSearchParams ¶
func (cmd *GrepCommand) GetSearchParams() SearchParameters
GetSearchParams returns the search parameters the command was run with
func (*GrepCommand) IsSane ¶
func (cmd *GrepCommand) IsSane() bool
IsSane returns true if command is sane
func (*GrepCommand) Parse ¶
func (cmd *GrepCommand) Parse(args []string) error
Parse given arguments and return status
func (*GrepCommand) PrintUsage ¶
func (cmd *GrepCommand) PrintUsage()
PrintUsage print command usage
func (*GrepCommand) Run ¶
func (cmd *GrepCommand) Run() int
Run executes 'grep' with given GrepCommand's parameters
type GrepCommandArgs ¶
type GrepCommandArgs struct {
Search string `arg:"positional,required"`
Path string `arg:"positional"`
Keys bool `arg:"-k,--keys" help:"Match against keys (true if -v is not specified)"`
Regexp bool `arg:"-e,--regexp" help:"Treat search string as a regexp"`
Shallow bool `arg:"-S,--shallow" help:"Only search leaf nodes of the path rather than recurse deeper"`
Values bool `arg:"-v,--values" help:"Match against values (true if -k is not specified)"`
}
GrepCommandArgs provides a struct for go-arg parsing
func (GrepCommandArgs) Description ¶
func (GrepCommandArgs) Description() string
Description provides detail on what the command does
type KeyValueCommand ¶
type KeyValueCommand interface {
IsMode(mode KeyValueMode) bool
}
KeyValueCommand interface to describe a command that supports Key and/or Value scoping
type KeyValueMode ¶
type KeyValueMode int
KeyValueMode defines the scope of which parts of a path to search (keys and/or values)
const ( // ModeKeys only searches keys ModeKeys KeyValueMode = 1 // ModeValues only searches values ModeValues KeyValueMode = 2 )
type ListCommand ¶
type ListCommand struct {
// contains filtered or unexported fields
}
ListCommand container for 'ls' parameters
func NewListCommand ¶
func NewListCommand(c *client.Client) *ListCommand
NewListCommand creates a new ListCommand parameter container
func (*ListCommand) GetArgs ¶
func (cmd *ListCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
func (*ListCommand) GetName ¶
func (cmd *ListCommand) GetName() string
GetName returns the ListCommand's name identifier
func (*ListCommand) IsSane ¶
func (cmd *ListCommand) IsSane() bool
IsSane returns true if command is sane
func (*ListCommand) Parse ¶
func (cmd *ListCommand) Parse(args []string) error
Parse given arguments and return status
func (*ListCommand) PrintUsage ¶
func (cmd *ListCommand) PrintUsage()
PrintUsage print command usage
func (*ListCommand) Run ¶
func (cmd *ListCommand) Run() int
Run executes 'ls' with given ListCommand's parameters
type ListCommandArgs ¶
type ListCommandArgs struct {
Path string `arg:"positional" help:"path to list contents of, defaults to current path"`
}
ListCommandArgs provides a struct for go-arg parsing
func (ListCommandArgs) Description ¶
func (ListCommandArgs) Description() string
Description provides detail on what the command does
type Match ¶
type Match struct {
// contains filtered or unexported fields
}
Match structure to keep indices of matched and replaced terms
type MatchOutput ¶
type MatchOutput string
MatchOutput contains the possible ways of presenting a match
const ( // MatchOutputHighlight outputs yellow highlighted matching text MatchOutputHighlight MatchOutput = "highlight" // MatchOutputInline outputs red and green text to show replacements MatchOutputInline MatchOutput = "inline" // MatchOutputDiff outputs addition and subtraction lines to show replacements MatchOutputDiff MatchOutput = "diff" )
type MatchOutputArg ¶
type MatchOutputArg struct {
Value MatchOutput
}
MatchOutputArg provides a struct to custom validate an arg
func (*MatchOutputArg) UnmarshalText ¶
func (a *MatchOutputArg) UnmarshalText(b []byte) error
UnmarshalText validates the MatchOutputArg
type MoveCommand ¶
type MoveCommand struct {
// contains filtered or unexported fields
}
MoveCommand container for all 'mv' parameters
func NewMoveCommand ¶
func NewMoveCommand(c *client.Client, workerCount int) *MoveCommand
NewMoveCommand creates a new MoveCommand parameter container
func (*MoveCommand) GetArgs ¶
func (cmd *MoveCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
func (*MoveCommand) GetName ¶
func (cmd *MoveCommand) GetName() string
GetName returns the MoveCommand's name identifier
func (*MoveCommand) IsSane ¶
func (cmd *MoveCommand) IsSane() bool
IsSane returns true if command is sane
func (*MoveCommand) Parse ¶
func (cmd *MoveCommand) Parse(args []string) error
Parse given arguments and return status
func (*MoveCommand) PrintUsage ¶
func (cmd *MoveCommand) PrintUsage()
PrintUsage print command usage
func (*MoveCommand) Run ¶
func (cmd *MoveCommand) Run() int
Run executes 'mv' with given MoveCommand's parameters
type MoveCommandArgs ¶
type MoveCommandArgs struct {
Source string `arg:"positional,required" help:"path to move"`
Target string `arg:"positional,required" help:"path to move source to"`
}
MoveCommandArgs provides a struct for go-arg parsing
func (MoveCommandArgs) Description ¶
func (MoveCommandArgs) Description() string
Description provides detail on what the command does
type RemoveCommand ¶
type RemoveCommand struct {
// contains filtered or unexported fields
}
RemoveCommand container for all 'rm' parameters
func NewRemoveCommand ¶
func NewRemoveCommand(c *client.Client, workerCount int, interactive bool) *RemoveCommand
NewRemoveCommand creates a new RemoveCommand parameter container
func (*RemoveCommand) Confirm ¶
func (cmd *RemoveCommand) Confirm() bool
Confirm prompts the user before a recursive removal. It returns false when the user declines, which causes the caller to skip Run(). Called outside RunWithSpinner so the spinner never races with the stdin read.
func (*RemoveCommand) GetArgs ¶
func (cmd *RemoveCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
func (*RemoveCommand) GetName ¶
func (cmd *RemoveCommand) GetName() string
GetName returns the RemoveCommand's name identifier
func (*RemoveCommand) IsSane ¶
func (cmd *RemoveCommand) IsSane() bool
IsSane returns true if command is sane
func (*RemoveCommand) Parse ¶
func (cmd *RemoveCommand) Parse(args []string) error
Parse given arguments and return status
func (*RemoveCommand) PrintUsage ¶
func (cmd *RemoveCommand) PrintUsage()
PrintUsage print command usage
func (*RemoveCommand) Run ¶
func (cmd *RemoveCommand) Run() int
Run executes 'rm' with given RemoveCommand's parameters
type RemoveCommandArgs ¶
type RemoveCommandArgs struct {
Recursive bool `arg:"-r" help:"recursively remove a directory"`
Force bool `arg:"-f" help:"skip confirmation prompt for recursive removal"`
Path string `arg:"positional,required" help:"path to remove"`
}
RemoveCommandArgs provides a struct for go-arg parsing
func (RemoveCommandArgs) Description ¶
func (RemoveCommandArgs) Description() string
Description provides detail on what the command does
type ReplaceCommand ¶
type ReplaceCommand struct {
Mode KeyValueMode
// contains filtered or unexported fields
}
ReplaceCommand container for all 'replace' parameters
func NewReplaceCommand ¶
func NewReplaceCommand(c *client.Client, workerCount int) *ReplaceCommand
NewReplaceCommand creates a new ReplaceCommand parameter container
func (*ReplaceCommand) FindReplacements ¶
func (cmd *ReplaceCommand) FindReplacements( search string, replacement string, path string, ) (matches []*Match, err error)
FindReplacements will find the matches for a given search string to be replaced
func (*ReplaceCommand) GetArgs ¶
func (cmd *ReplaceCommand) GetArgs() interface{}
GetArgs provides the struct holding arguments for the command
func (*ReplaceCommand) GetName ¶
func (cmd *ReplaceCommand) GetName() string
GetName returns the ReplaceCommand's name identifier
func (*ReplaceCommand) GetSearchParams ¶
func (cmd *ReplaceCommand) GetSearchParams() SearchParameters
GetSearchParams returns the search parameters the command was run with
func (*ReplaceCommand) IsSane ¶
func (cmd *ReplaceCommand) IsSane() bool
IsSane returns true if command is sane
func (*ReplaceCommand) Parse ¶
func (cmd *ReplaceCommand) Parse(args []string) error
Parse given arguments and return status
func (*ReplaceCommand) PrintUsage ¶
func (cmd *ReplaceCommand) PrintUsage()
PrintUsage print command usage
func (*ReplaceCommand) Run ¶
func (cmd *ReplaceCommand) Run() int
Run executes 'replace' with given ReplaceCommand's parameters
func (*ReplaceCommand) SetSpinnerControl ¶
func (cmd *ReplaceCommand) SetSpinnerControl(pause, resume func())
SetSpinnerControl satisfies SpinnerAware so the spinner can be paused while askForConfirmation is reading stdin.
func (*ReplaceCommand) WriteReplacements ¶
func (cmd *ReplaceCommand) WriteReplacements(groupedMatches map[string][]*Match) error
WriteReplacements will write replacement data back to Vault concurrently
type ReplaceCommandArgs ¶
type ReplaceCommandArgs struct {
Search string `arg:"positional,required"`
Replacement string `arg:"positional,required"`
Path string `arg:"positional"`
Confirm bool `arg:"-y,--confirm" help:"Write results without prompt"`
DryRun bool `arg:"-n,--dry-run" help:"Skip writing results without prompt"`
KeySelector string `arg:"-s,--key-selector" help:"Limit replacements to specified key" placeholder:"PATTERN"`
Keys bool `arg:"-k,--keys" help:"Match against keys (true if -v is not specified)"`
Output MatchOutputArg `` /* 133-byte string literal not displayed */
Regexp bool `arg:"-e,--regexp" help:"Treat search string and selector as a regexp"`
Shallow bool `arg:"-S,--shallow" help:"Only search leaf nodes of the path rather than recurse deeper"`
Values bool `arg:"-v,--values" help:"Match against values (true if -k is not specified)"`
}
ReplaceCommandArgs provides a struct for go-arg parsing
func (ReplaceCommandArgs) Description ¶
func (ReplaceCommandArgs) Description() string
Description provides detail on what the command does
type SearchParameters ¶
type SearchParameters struct {
Search string
Replacement *string
KeySelector string
Mode KeyValueMode
IsRegexp bool
Output MatchOutput
}
SearchParameters struct are parameters common to a command that performs a search operation
type Searcher ¶
type Searcher struct {
// contains filtered or unexported fields
}
Searcher provides matching and replacement methods while maintaining references to the command that provides an interface to search operations. Also maintains reference to a compiled regexp.
func NewSearcher ¶
func NewSearcher(cmd SearchingCommand) (*Searcher, error)
NewSearcher creates a new Searcher container for performing search and optionally replace
func (*Searcher) IsMode ¶
func (s *Searcher) IsMode(mode KeyValueMode) bool
IsMode returns true if the specified mode is enabled
type SearchingCommand ¶
type SearchingCommand interface {
GetSearchParams() SearchParameters
}
SearchingCommand interface to describe a command that performs a search operation
type SpinnerAware ¶
type SpinnerAware interface {
SetSpinnerControl(pause, resume func())
}
SpinnerAware is implemented by commands that call interactive prompts mid-execution and need to pause the spinner to avoid corrupted output.