Move global config to XDG location (~/.config/projector/config.toml)#27
Merged
Conversation
Change the default global config location to the XDG-style $XDG_CONFIG_HOME/projector/config.toml (defaulting to ~/.config/projector/config.toml), matching gh/mise/iterm2 conventions and reducing home-directory clutter. Backwards compatible: - Load prefers the new location, then falls back to the legacy ~/.projector/projector-config.toml. - When config is found only at the legacy location, it is copy-migrated to the new location (legacy file left in place for older pj binaries) and a message is printed to stdout. - Save always targets the new location. ConfigDir/ConfigFilePath now honor $XDG_CONFIG_HOME. Added tests for resolution order, migration, XDG override, and the no-config case. Updated docs (commands.md, CLAUDE.md, pj-skill.md) and the config command help text. Closes #22 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Keeps stdout clean for machine-readable commands like `pj path` and `pj config get`. 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.
What & why
Closes #22. Moves the default global config from
~/.projector/projector-config.tomlto the XDG-style~/.config/projector/config.toml, matching the conventions used bygh,mise, anditerm2and reducing home-directory clutter.ConfigDir/ConfigFilePathnow honor$XDG_CONFIG_HOME:$XDG_CONFIG_HOMEis set:$XDG_CONFIG_HOME/projector/config.toml.~/.config/projector/config.toml(XDG default base~/.config).Backwards-compatibility / resolution order
config.Load()resolves in this order:$XDG_CONFIG_HOME/projector/config.toml, default~/.config/projector/config.toml) — preferred.~/.projector/projector-config.toml) — fallback when the new file is absent.ErrNotFound(treated as not-yet-configured, same as before).config.Save()always writes to the new location.Migration semantics: copy, not move
When the config exists only at the legacy location,
Loadcopies it to the new location (creating~/.config/projector/), leaves the legacy file untouched, and prints a one-line notice to stdout:Rationale for copy-vs-move: copying is the safer choice for users who may still run an older
pjbinary that only reads the legacy path — both binaries keep working. Migration is best-effort: if the copy fails (e.g. read-only~/.config),Loadstill loads directly from the legacy file rather than failing the command. SinceSavetargets the new location, the two files can diverge after a subsequent write; this is the accepted trade-off for keeping older binaries functional, andLoadalways prefers the new file once it exists.Tests
Added/updated tests in
internal/config/config_test.go:$XDG_CONFIG_HOMEoverride and default-to-~/.configSavewrites to new location onlyErrNotFoundThe shared test helper now also clears
XDG_CONFIG_HOMEto keep resolution self-contained.Docs
Updated
docs/commands.md(incl. a note on the XDG location + legacy fallback/migration),CLAUDE.md(config package row),pj-skill.md, and thepj configcommandShorthelp text.Verification
Locally:
go build ./cmd/projector,go vet ./..., andgo test -race -count=1 ./...all pass.For reviewers to scrutinize / not verified locally
pjreading legacy while newpjreads/writes the new path) is reasoned about, not exercised in CI.$XDG_CONFIG_HOMEis used verbatim if set; no validation that it is an absolute path (matches typical XDG tooling behavior).🤖 Generated with Claude Code