Repository navigation
feat: default config to ~/.config/taskbook/taskbook.json - #61
Merged
Merged
Conversation
Resolve the client config from the XDG location `~/.config/taskbook/taskbook.json` (honoring `$XDG_CONFIG_HOME`), falling back to the legacy `~/.taskbook.json` when it exists and the XDG file does not. New installs use the XDG path; existing installs keep working untouched. `~/.config` is used on every platform (not the OS-native config dir) to match the conventional Linux location requested in the issue. - create_dir_all the parent on first write / save - migrate-sync hint now prints the resolved config path - docs updated (README, docs/, CLAUDE.md) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Moves the taskbook client configuration file default from the legacy ~/.taskbook.json to the XDG-style location ~/.config/taskbook/taskbook.json (honoring $XDG_CONFIG_HOME), while preserving backward compatibility for existing installs.
Changes:
- Implement XDG-first config path resolution with legacy fallback and ensure parent directories exist on first write/save.
- Update CLI messaging to print the resolved config path.
- Update user and internal documentation to reflect the new default config location and migration guidance.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates the documented default config path to the new XDG location. |
| docs/sync.md | Updates sync instructions to reference the new config path (and mentions legacy). |
| docs/README.md | Updates the architecture overview to list the new config file location. |
| docs/configuration.md | Documents the new config location and the legacy fallback behavior. |
| crates/taskbook-client/src/config.rs | Adds XDG/legacy config path resolution logic, creates parent dirs on first write, and adds unit tests. |
| crates/taskbook-client/src/commands.rs | Updates the post-migrate hint to print the resolved config path. |
| CLAUDE.md | Updates internal docs to reflect the new config file location and resolution behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ## Configuration | ||
|
|
||
| Configuration is stored in `~/.taskbook.json`: | ||
| Configuration is stored in `~/.config/taskbook/taskbook.json` (honoring `$XDG_CONFIG_HOME`; a legacy `~/.taskbook.json` is still used if present): |
Comment on lines
110
to
114
| 5. **Directory Resolution Priority**: | ||
| - `--taskbook-dir` CLI flag (highest) | ||
| - `TASKBOOK_DIR` environment variable | ||
| - `~/.taskbook.json` config file | ||
| - config file (lowest) | ||
| - Default `~/.taskbook/` (lowest) |
Comment on lines
+288
to
+294
| fn xdg_config_path(home: &Path, xdg_env: Option<&OsStr>) -> PathBuf { | ||
| let base = match xdg_env.filter(|v| !v.is_empty()) { | ||
| Some(v) => PathBuf::from(v), | ||
| None => home.join(".config"), | ||
| }; | ||
| base.join("taskbook").join("taskbook.json") | ||
| } |
Comment on lines
+303
to
+311
| fn select_config_path(xdg: PathBuf, legacy: PathBuf) -> PathBuf { | ||
| if xdg.exists() { | ||
| xdg | ||
| } else if legacy.exists() { | ||
| legacy | ||
| } else { | ||
| xdg | ||
| } | ||
| } |
Comment on lines
315
to
+319
| fn ensure_config_file() -> Result<()> { | ||
| let config_path = Self::config_file_path(); | ||
| if !config_path.exists() { | ||
| if let Some(parent) = config_path.parent() { | ||
| fs::create_dir_all(parent)?; |
Comment on lines
+3
to
+5
| Client configuration is stored in `~/.config/taskbook/taskbook.json` (honoring `$XDG_CONFIG_HOME`). The file is created automatically with default values on first run. | ||
|
|
||
| For backward compatibility, if a legacy `~/.taskbook.json` exists and the XDG file does not, the legacy file is used. To migrate, move `~/.taskbook.json` to `~/.config/taskbook/taskbook.json`. |
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 #59.
What
Moves the default client config to the conventional XDG location.
Resolution order:
~/.config/taskbook/taskbook.json(honoring$XDG_CONFIG_HOME) — preferred~/.taskbook.json— used only if it exists and the XDG file does notBackward compatibility
Existing installs are untouched: if you already have
~/.taskbook.jsonand no XDG file, that legacy file keeps being used. To migrate, move it to~/.config/taskbook/taskbook.json.Notes
~/.configis used on every platform (notdirs::config_dir(), which returns~/Library/Application Supporton macOS) to match the Linux convention the issue asks for.$XDG_CONFIG_HOMEis honored.save()nowcreate_dir_alls the parent directory.~/.taskbook.json.Test plan
cargo test --workspace— green (new unit tests: XDG path default,$XDG_CONFIG_HOMEhonored, empty env var ignored, legacy path, and the 3-way selection logic)cargo clippy --workspace --all-targets— cleancargo fmt --all --check— clean🤖 Generated with Claude Code