Add --home CLI flag and TOML backslash error hints for Windows#87
Merged
Conversation
Windows users writing native backslash paths in config.toml get cryptic "invalid escape" errors from the TOML parser. This adds a helpful hint pointing to forward slashes, single quotes, or the new --home flag. The --home flag sets the home directory directly from the CLI, bypassing TOML config entirely — the most common need for Windows users who just want a custom data location. Closes #86 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously --home was applied after config loading, so a config.toml placed in the --home directory was silently ignored. Now --home is passed into Load() so it behaves like MSGVAULT_HOME: config.toml is loaded from that directory, and HomeDir/DataDir default to it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Paths like C:\Users\... trigger a different TOML error ("expected eight
hexadecimal digits after '\U'") than C:\Games\... ("invalid escape").
Match both patterns so the hint always appears for backslash paths.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Since --home now loads config.toml from that directory, it doesn't help avoid TOML parsing errors. Keep the hint focused on the fix: use forward slashes or single quotes. Co-Authored-By: Claude Opus 4.6 <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.
Summary
Closes #86
Windows users writing native backslash paths in
config.toml(e.g.data_dir = "C:\Users\wesmc\msgvault") get cryptic TOML parse errors because backslashes are escape characters in TOML double-quoted strings. This PR addresses the problem from two angles:1.
--homeCLI flag — Sets the home directory directly from the command line, equivalent toMSGVAULT_HOME. Config, database, tokens, attachments, and analytics all live under this directory. If aconfig.tomlexists there, it's loaded.2. Improved TOML error messages — When
config.tomlcontains backslash paths that fail to parse, the error now includes a hint:This catches both
\G-style "invalid escape" errors and\U-style "expected hexadecimal digits" errors.Changes
cmd/msgvault/cmd/root.go— Add--homepersistent flag, pass it intoconfig.Load()internal/config/config.go—Load()accepts ahomeDirparameter that overridesDefaultHome()before determining config path; detect backslash-related TOML errors and wrap with hintinternal/config/config_test.go— Tests for--home(sets HomeDir/DataDir, reads config.toml from home dir, expands tilde), tests for backslash hints (\Gand\Uvariants)CLAUDE.md— Add General Workflow, Go Development, and Git Workflow guidelinesTest plan
make testpassesmake lintpassesmsgvault.exe --home "C:\Users\wesmc\testing" init-dbuses the override directorydata_dir = "C:\Games\msgvault"shows the hintdata_dir = "C:\Users\wesmc\data"shows the hint (\Uvariant)--homedirectory is loaded (e.g.rate_limit_qpsapplies)🤖 Generated with Claude Code