summaryrefslogtreecommitdiff
path: root/internal/cli
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-17 08:44:55 +0300
committerPaul Buetow <paul@buetow.org>2026-04-17 08:44:55 +0300
commit426b9531c32d1afb154feea6e9818d59ff73d696 (patch)
tree3da298f586c479ea41c26c4f2b1cb14e66a47601 /internal/cli
parentdccb8ff6630727418ed8292834e9703cf2e4d72a (diff)
refactor: extract Backend interface decoupling CLI from *store.Store (task j4)
Add internal/backend/backend.go with a Backend interface covering all 10 CLI-facing methods. Change CLI.st field type to backend.Backend. Compile-time guard var _ Backend = (*store.Store)(nil) prevents drift. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/cli')
-rw-r--r--internal/cli/cli.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go
index c8a271a..dc1c2ba 100644
--- a/internal/cli/cli.go
+++ b/internal/cli/cli.go
@@ -16,6 +16,7 @@ import (
"strings"
"time"
+ "codeberg.org/snonux/foostore/internal/backend"
"codeberg.org/snonux/foostore/internal/clipboard"
"codeberg.org/snonux/foostore/internal/config"
"codeberg.org/snonux/foostore/internal/crypto"
@@ -50,9 +51,15 @@ var SearchActions = map[string]store.Action{
// lastResult is updated by dispatch and used as a fallback search term when
// a search-based command is invoked without an explicit term (mirrors Ruby's
// @last_result instance variable).
+//
+// st is declared as backend.Backend (interface) rather than *store.Store
+// (concrete type) so that alternative backends (e.g. KeePass) can be swapped
+// in without touching the dispatch or shell-loop logic. The current geheim
+// backend is *store.Store, which satisfies Backend via the compile-time check
+// in internal/backend/backend.go.
type CLI struct {
cfg *config.Config
- st *store.Store
+ st backend.Backend
g *git.Git
clip *clipboard.Clipboard
sh *shell.Shell