commit 6d7c649a3dcecbf0b0aa4bb69f692f28172d9d51
parent 6bf9d938523fc2c587c2af2f21e92a4fe1b5bd19
Author: Sean Enck <sean@ttypty.com>
Date: Sat, 2 Nov 2024 09:11:23 -0400
add hook docs
Diffstat:
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/internal/app/core.go b/internal/app/core.go
@@ -118,6 +118,17 @@ type (
KeyFile string
NoKey string
}
+ Hooks struct {
+ Mode struct {
+ Pre string
+ Post string
+ }
+ Action struct {
+ Remove string
+ Insert string
+ Move string
+ }
+ }
}
)
@@ -243,6 +254,11 @@ func Usage(verbose bool, exe string) ([]string, error) {
}
document.ReKey.KeyFile = setDocFlag(config.ReKeyFlags.KeyFile)
document.ReKey.NoKey = config.ReKeyFlags.NoKey
+ document.Hooks.Mode.Pre = string(backend.HookPre)
+ document.Hooks.Mode.Post = string(backend.HookPost)
+ document.Hooks.Action.Insert = string(backend.InsertAction)
+ document.Hooks.Action.Remove = string(backend.RemoveAction)
+ document.Hooks.Action.Move = string(backend.MoveAction)
files, err := docs.ReadDir(docDir)
if err != nil {
return nil, err
diff --git a/internal/app/core_test.go b/internal/app/core_test.go
@@ -13,7 +13,7 @@ func TestUsage(t *testing.T) {
t.Errorf("invalid usage, out of date? %d", len(u))
}
u, _ = app.Usage(true, "lb")
- if len(u) != 116 {
+ if len(u) != 126 {
t.Errorf("invalid verbose usage, out of date? %d", len(u))
}
for _, usage := range u {
diff --git a/internal/app/doc/hooks.txt b/internal/app/doc/hooks.txt
@@ -0,0 +1,9 @@
+When hooks are enabled the files in the specified hook directory
+are executed with the following parameters (in this order):
+
+- string: "{{ .Hooks.Mode.Pre }}" or "{{ .Hooks.Mode.Post }}" representing when the hook is executing.
+
+- string: "{{ .Hooks.Action.Move }}", "{{ .Hooks.Action.Insert }}", or "{{
+ .Hooks.Action.Remove }}" indicating the user action
+
+- string: the path to the entry being operated on