summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-29 16:02:24 +0300
committerPaul Buetow <paul@buetow.org>2026-04-29 16:02:24 +0300
commit751c82f337f9dc4756846cf7c547d31668d6587d (patch)
treef607ea6bfad096d8e0085ca115d69aab52cccf06 /cmd
parent3c1523cc7794da059912c70fb82a708047bc6d72 (diff)
Short-circuit `foostore fish` to skip backend initHEADv0.8.1master
The fish subcommand prints a purely static shell-integration script and needs no backend, cipher, store, git, or shell. Previously cli.New ran in main() before dispatch, triggering the KeePass Argon2 KDF and adding ~1.8s to every interactive fish shell startup that sources the script. Export FishIntegrationScript and dispatch `fish` directly from main() before constructing the CLI. Local timing: `foostore fish` drops from ~1.834s to ~0.003s. Bump version to v0.8.1. Amp-Thread-ID: https://ampcode.com/threads/T-019dd950-11ef-77aa-bb92-810f22601023 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/foostore/main.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmd/foostore/main.go b/cmd/foostore/main.go
index 82283da..1e7a184 100644
--- a/cmd/foostore/main.go
+++ b/cmd/foostore/main.go
@@ -28,6 +28,20 @@ func main() {
os.Exit(0)
}
+ // Short-circuit the "fish" subcommand: it emits a purely static shell
+ // integration script and needs no backend, cipher, store, git, or shell
+ // initialisation. Skipping cli.New avoids the KeePass Argon2 KDF cost
+ // (~1.8s), which makes every interactive fish shell startup that sources
+ // `foostore fish | source` correspondingly faster.
+ if len(args) == 1 && args[0] == "fish" {
+ binaryPath, err := os.Executable()
+ if err != nil {
+ binaryPath = "foostore"
+ }
+ fmt.Print(cli.FishIntegrationScript(binaryPath))
+ os.Exit(0)
+ }
+
// Cancel the context on SIGINT or SIGTERM so that long-running operations
// (fzf, external editors) terminate gracefully rather than being killed hard.
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)