feat(completions): wire up key completions for key commands
This commit is contained in:
parent
84b1c67c72
commit
bc0b98c7f9
5 changed files with 32 additions and 25 deletions
|
|
@ -22,9 +22,10 @@ Binary values are presented as base64 for editing and decoded back on save.
|
||||||
|
|
||||||
Metadata flags (--ttl, --encrypt, --decrypt) can be passed alongside the edit
|
Metadata flags (--ttl, --encrypt, --decrypt) can be passed alongside the edit
|
||||||
to modify metadata in the same operation.`,
|
to modify metadata in the same operation.`,
|
||||||
Aliases: []string{"e"},
|
Aliases: []string{"e"},
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: edit,
|
ValidArgsFunction: completeKeys,
|
||||||
|
RunE: edit,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
12
cmd/get.go
12
cmd/get.go
|
|
@ -46,9 +46,10 @@ additional argument after the initial KEY being fetched.
|
||||||
For example:
|
For example:
|
||||||
pda set greeting 'Hello, {{ .NAME }}!'
|
pda set greeting 'Hello, {{ .NAME }}!'
|
||||||
pda get greeting NAME=World`,
|
pda get greeting NAME=World`,
|
||||||
Aliases: []string{"g"},
|
Aliases: []string{"g"},
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
RunE: get,
|
ValidArgsFunction: completeKeys,
|
||||||
|
RunE: get,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,8 +64,9 @@ additional argument after the initial KEY being fetched.
|
||||||
For example:
|
For example:
|
||||||
pda set greeting 'Hello, {{ .NAME }}!'
|
pda set greeting 'Hello, {{ .NAME }}!'
|
||||||
pda run greeting NAME=World`,
|
pda run greeting NAME=World`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
RunE: run,
|
ValidArgsFunction: completeKeys,
|
||||||
|
RunE: run,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,9 @@ var metaCmd = &cobra.Command{
|
||||||
without changing its value.
|
without changing its value.
|
||||||
|
|
||||||
With no flags, displays the key's current metadata. Pass flags to modify.`,
|
With no flags, displays the key's current metadata. Pass flags to modify.`,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
RunE: meta,
|
ValidArgsFunction: completeKeys,
|
||||||
|
RunE: meta,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
26
cmd/mv.go
26
cmd/mv.go
|
|
@ -30,21 +30,23 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var cpCmd = &cobra.Command{
|
var cpCmd = &cobra.Command{
|
||||||
Use: "copy FROM[@STORE] TO[@STORE]",
|
Use: "copy FROM[@STORE] TO[@STORE]",
|
||||||
Aliases: []string{"cp"},
|
Aliases: []string{"cp"},
|
||||||
Short: "Make a copy of a key",
|
Short: "Make a copy of a key",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: cp,
|
ValidArgsFunction: completeKeys,
|
||||||
SilenceUsage: true,
|
RunE: cp,
|
||||||
|
SilenceUsage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
var mvCmd = &cobra.Command{
|
var mvCmd = &cobra.Command{
|
||||||
Use: "move FROM[@STORE] TO[@STORE]",
|
Use: "move FROM[@STORE] TO[@STORE]",
|
||||||
Aliases: []string{"mv"},
|
Aliases: []string{"mv"},
|
||||||
Short: "Move a key",
|
Short: "Move a key",
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: mv,
|
ValidArgsFunction: completeKeys,
|
||||||
SilenceUsage: true,
|
RunE: mv,
|
||||||
|
SilenceUsage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func cp(cmd *cobra.Command, args []string) error {
|
func cp(cmd *cobra.Command, args []string) error {
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,10 @@ For example:
|
||||||
'Hello, {{ default "World" .NAME }}' will default to World if NAME is blank.
|
'Hello, {{ default "World" .NAME }}' will default to World if NAME is blank.
|
||||||
'Hello, {{ require .NAME }}' will error if NAME is blank.
|
'Hello, {{ require .NAME }}' will error if NAME is blank.
|
||||||
'{{ enum .NAME "Alice" "Bob" }}' allows only NAME=Alice or NAME=Bob.`,
|
'{{ enum .NAME "Alice" "Bob" }}' allows only NAME=Alice or NAME=Bob.`,
|
||||||
Aliases: []string{"s"},
|
Aliases: []string{"s"},
|
||||||
Args: cobra.RangeArgs(1, 2),
|
Args: cobra.RangeArgs(1, 2),
|
||||||
RunE: set,
|
ValidArgsFunction: completeKeys,
|
||||||
|
RunE: set,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue