Skip to content

feat: default config to ~/.config/taskbook/taskbook.json - #61

Merged
alexanderdavidsen merged 1 commit into
masterfrom
feat/xdg-config
Jun 24, 2026
Merged

alexanderdavidsen merged 1 commit into
masterfrom
feat/xdg-config

Conversation

@alexanderdavidsen

Copy link
Copy Markdown
Collaborator

Closes #59.

What

Moves the default client config to the conventional XDG location.

Resolution order:

  1. ~/.config/taskbook/taskbook.json (honoring $XDG_CONFIG_HOME) — preferred
  2. legacy ~/.taskbook.json — used only if it exists and the XDG file does not
  3. otherwise the XDG path (new installs)

Backward compatibility

Existing installs are untouched: if you already have ~/.taskbook.json and no XDG file, that legacy file keeps being used. To migrate, move it to ~/.config/taskbook/taskbook.json.

Notes

  • ~/.config is used on every platform (not dirs::config_dir(), which returns ~/Library/Application Support on macOS) to match the Linux convention the issue asks for. $XDG_CONFIG_HOME is honored.
  • First write / save() now create_dir_alls the parent directory.
  • The post-migrate "enable sync" hint now prints the resolved config path instead of a hardcoded ~/.taskbook.json.
  • Docs updated (README, docs/configuration.md, docs/sync.md, docs/README.md, CLAUDE.md).

Test plan

  • cargo test --workspace — green (new unit tests: XDG path default, $XDG_CONFIG_HOME honored, empty env var ignored, legacy path, and the 3-way selection logic)
  • cargo clippy --workspace --all-targets — clean
  • cargo fmt --all --check — clean

🤖 Generated with Claude Code

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]>
Copilot AI review requested due to automatic review settings June 24, 2026 11:10
@alexanderdavidsen
alexanderdavidsen merged commit c51b4fa into master Jun 24, 2026
4 checks passed
@alexanderdavidsen
alexanderdavidsen deleted the feat/xdg-config branch June 24, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread README.md
## 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 thread CLAUDE.md
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 thread docs/configuration.md
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

default config location as ~/.config/taskbook

2 participants