Skip to content

feat: move config to XDG path with legacy migration warning#14

Merged
rrbe merged 2 commits into
masterfrom
feat/config-xdg-location
May 29, 2026
Merged

feat: move config to XDG path with legacy migration warning#14
rrbe merged 2 commits into
masterfrom
feat/config-xdg-location

Conversation

@rrbe
Copy link
Copy Markdown
Owner

@rrbe rrbe commented May 29, 2026

Summary

Migrates termdown's config directory from ~/.termdown/ to the XDG path ~/.config/termdown/ (honoring $XDG_CONFIG_HOME), and avoids silently dropping existing user settings during the upgrade.

Changes

  • config_dir() now prefers an absolute $XDG_CONFIG_HOME, otherwise falls back to ~/.config/termdown (USERPROFILE covers Windows). Relative/empty XDG_CONFIG_HOME is ignored per the XDG spec.
  • Legacy migration warning: if load() finds no config at the new path but a ~/.termdown/config.toml still exists, it prints a one-line stderr warning instead of failing silently.
  • uninstall.sh removes both the new and legacy config dirs, and mirrors the loader's "absolute $XDG_CONFIG_HOME only" rule so it deletes what the binary actually reads.
  • config.example.toml (new) documents every default, copy-pasteable.
  • Docs sweep: README / README_CN / ARCHITECTURE / ADR-0001 / CONTEXT / MARKDOWN_FEATURE_COVERAGE / TUI_MODE_DESIGN / --help / CHANGELOG all point at the new path.

Tests

  • xdg_config_home_is_honored_for_config_loading — proves a config.toml under $XDG_CONFIG_HOME/termdown/ actually loads.
  • legacy_config_location_triggers_migration_warning — asserts the migration warning fires.
  • example_config_parses_and_matches_defaults — guards config.example.toml against drift via include_str!.
  • Both CLI/snapshot harnesses now also clear XDG_CONFIG_HOME so a developer's real config can't leak into tests.

make check passes clean (fmt-check + clippy -D warnings + tests).

Breaking change

Existing users must move ~/.termdown/config.toml~/.config/termdown/config.toml. The new warning nudges them; pre-1.0 so acceptable.

🤖 Generated with Claude Code

rrbe and others added 2 commits May 29, 2026 11:26
termdown now reads ~/.config/termdown/config.toml (or
$XDG_CONFIG_HOME/termdown/config.toml) instead of ~/.termdown/config.toml.
When a legacy ~/.termdown/config.toml is found while the new path is empty,
it warns rather than dropping the old settings silently.

- config_dir() honors an absolute $XDG_CONFIG_HOME, else ~/.config
- uninstall.sh removes both new and legacy dirs, mirroring the loader's
  absolute-XDG rule
- add config.example.toml documenting every default
- tests for XDG loading, the migration warning, and example-file drift
- sweep docs/README/CHANGELOG/ADR to the new path

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Windows CI run failed because `Path::display` emits `\` separators,
so `contains(".termdown/config.toml")` never matched. Assert on the
distinctive `.termdown` legacy dir name instead, which holds on all platforms.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rrbe rrbe merged commit 5e8164f into master May 29, 2026
5 checks passed
@rrbe rrbe deleted the feat/config-xdg-location branch May 29, 2026 15:36
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.

1 participant