fix(cli): honor top-level --db when a subcommand follows (#313)#314
Merged
Conversation
`mimir --db PATH serve` silently ignored the flag and used the subcommand's default db path — a serious footgun for MCP host configs (`args: ["--db", P, "serve"]` connected to the wrong database with no warning). The top-level `--db` is documented for `mimir --db PATH` but was never propagated once a subcommand was present; each subcommand's own defaulted `--db` won. Propagate the top-level `--db` into the subcommand when the user didn't pass a subcommand-level one (i.e. it still equals the default). An explicit subcommand-level `--db` always wins; ObsidianSync's Option<String> db is filled when None. Added a `Commands::db_field_mut()` accessor + `apply_top_level_db()` called once in main(), plus tests for the propagate / explicit-wins / obsidian cases. Verified e2e: `mimir --db P stats` now creates/opens the DB at P. Closes #313. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #313.
mimir --db PATH servesilently ignored--dband used the subcommand's default path — any MCP host config usingargs: ["--db", "/path", "serve"]connected to the wrong database with no warning (and the Perseus connector default used exactly this pattern, see perseus#528).Fix
The top-level
--db(documented formimir --db PATH) is now propagated into a following subcommand when the user didn't pass a subcommand-level--db(it still equals the default). An explicit subcommand--dbalways wins;obsidian-sync'sOptiondb is filled whenNone. Centralized inapply_top_level_db()(one call inmain()) + aCommands::db_field_mut()accessor.Tests
top_level_db_propagates_to_serve_subcommand,..._to_obsidian_sync,explicit_subcommand_db_wins_over_top_level(new); existingparses_serve_with_dbstill green.mimir --db P statscreates/opens the DB atP(was: default path).