commit c30d0c248d15aafba4bdc8616e216d813717bffb
parent 9b7ebca42742958668aca2a4f4c43bbd9794533c
Author: Sean Enck <sean@ttypty.com>
Date: Fri, 15 Jul 2022 18:36:40 -0400
cleaned up a bit
Diffstat:
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/cmd/lb/main.go b/cmd/lb/main.go
@@ -138,12 +138,12 @@ func main() {
case "show", "-c", "clip", "dump":
isDump := command == "dump"
startEntry := 2
- confirmDump := true
+ options := internal.Arguments{}
if isDump {
if len(args) > 2 {
- if args[2] == "-yes" {
+ options = internal.ParseArgs(args[2])
+ if options.Yes {
startEntry = 3
- confirmDump = false
}
}
}
@@ -215,7 +215,7 @@ func main() {
internal.CopyToClipboard(value)
}
if isDump {
- if confirmDump {
+ if !options.Yes {
if !confirm("dump data to stdout as plaintext") {
return
}
diff --git a/internal/args.go b/internal/args.go
@@ -8,6 +8,7 @@ type (
Short bool
List bool
Multi bool
+ Yes bool
}
)
@@ -19,5 +20,6 @@ func ParseArgs(arg string) Arguments {
args.Short = arg == "-short"
args.List = arg == "-ls" || arg == "-list"
args.Multi = arg == "-m" || arg == "-multi"
+ args.Yes = arg == "-yes"
return args
}
diff --git a/internal/hooks.go b/internal/hooks.go
@@ -7,16 +7,22 @@ import (
)
type (
+ // HookAction are specific steps that may call a hook.
HookAction string
+ // HookStep is the step, during command execution, when the hook was called.
HookStep string
)
const (
+ // RemoveHook is called when a store entry is removed.
RemoveHook HookAction = "remove"
+ // InsertHook is called when a store entry is inserted.
InsertHook HookAction = "insert"
+ // PostHookStep is a hook running at the end of a command.
PostHookStep HookStep = "post"
)
+// Hooks executes any configured hooks.
func Hooks(store string, action HookAction, step HookStep) error {
hookDir := os.Getenv("LOCKBOX_HOOKDIR")
if !PathExists(hookDir) {