feat(set): --secret flag to mark input as a secret
This commit is contained in:
parent
5cdcc1d3d3
commit
42735143e7
2 changed files with 15 additions and 1 deletions
12
cmd/set.go
12
cmd/set.go
|
|
@ -50,12 +50,21 @@ func set(cmd *cobra.Command, args []string) error {
|
|||
value = bytes
|
||||
}
|
||||
|
||||
secret, err := cmd.Flags().GetBool("secret")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
trans := TransactionArgs{
|
||||
key: args[0],
|
||||
readonly: false,
|
||||
sync: false,
|
||||
transact: func(tx *badger.Txn, k []byte) error {
|
||||
return tx.Set(k, value)
|
||||
entry := badger.NewEntry(k, value)
|
||||
if secret {
|
||||
entry = entry.WithMeta(metaSecret)
|
||||
}
|
||||
return tx.SetEntry(entry)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -64,4 +73,5 @@ func set(cmd *cobra.Command, args []string) error {
|
|||
|
||||
func init() {
|
||||
rootCmd.AddCommand(setCmd)
|
||||
setCmd.Flags().Bool("secret", false, "Mark the stored value as a secret")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue