summaryrefslogtreecommitdiff
path: root/internal/cli/migrate_kdbx.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-17 09:04:29 +0300
committerPaul Buetow <paul@buetow.org>2026-04-17 09:04:29 +0300
commit58349705d5adafa60b8a1dddd0f5c72bad568d3b (patch)
treeeefad461de05ad027936c44a3f73925ed1fce652 /internal/cli/migrate_kdbx.go
parenteb89e32c6675d4ed50f66580346e5ea8f3d7b5b2 (diff)
refactor: extract buildGeheimGit helper to keep buildGeheimBackend under 30 lines
Extracts a 3-line buildGeheimGit(cfg) helper from buildGeheimBackend, mirroring the existing buildKeepassGit pattern and satisfying the project guideline of keeping functions under 30 lines. Also includes the full o4 backend-abstraction changeset: Gitter interface, git.NoOp, --backend flag parsing, keepass backend wiring, and effectiveBackend guard for migrate-kdbx. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/cli/migrate_kdbx.go')
-rw-r--r--internal/cli/migrate_kdbx.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/cli/migrate_kdbx.go b/internal/cli/migrate_kdbx.go
index bc98d96..64241ac 100644
--- a/internal/cli/migrate_kdbx.go
+++ b/internal/cli/migrate_kdbx.go
@@ -31,6 +31,17 @@ type migrateKDBXStats struct {
}
func (c *CLI) cmdMigrateKDBX(ctx context.Context, argv []string) int {
+ // migrate-kdbx only makes sense when the source is the geheim backend.
+ // Refuse early when the active backend is already keepass to avoid
+ // accidentally migrating keepass→keepass.
+ // We check c.effectiveBackend (which incorporates the --backend flag override)
+ // rather than c.cfg.Backend (config file only) so that "foostore --backend keepass
+ // migrate-kdbx" is correctly rejected even when cfg.Backend is empty.
+ if c.effectiveBackend == "keepass" {
+ warn("migrate-kdbx is not supported when the active backend is 'keepass'; it migrates geheim→keepass only")
+ return 1
+ }
+
opts, err := c.parseMigrateKDBXOptions(argv)
if err != nil {
warn(err.Error())