Add support for XDG base directory config#51
Open
omroux wants to merge 1 commit intoopen-pomodoro:mainfrom
Open
Add support for XDG base directory config#51omroux wants to merge 1 commit intoopen-pomodoro:mainfrom
omroux wants to merge 1 commit intoopen-pomodoro:mainfrom
Conversation
7a3853a to
c431d2a
Compare
88ba472 to
e745494
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for XDG base directory specifications to prevent polluting the home directory, while maintaining backward compatibility with the legacy ~/.pomodoro configuration location.
Changes:
- Added
github.com/adrg/xdgdependency for XDG base directory support - Implemented directory resolution logic that prioritizes explicit flags, falls back to legacy
~/.pomodoroif it exists, then uses XDG config directory (~/.config/pomodoro) - Updated documentation to reflect the new default configuration directory
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| go.mod | Added xdg library dependency and updated testify version |
| cmd/root.go | Implemented resolveDirectory function with XDG support and legacy fallback logic |
| README.md | Updated documentation examples to use new XDG-compliant default path |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| viper.AutomaticEnv() | ||
|
|
||
| directoryFlag = resolveDirectory(directoryFlag) |
There was a problem hiding this comment.
The directoryFlag is being resolved in init() before command parsing occurs, which means the flag value will always be empty at this point. This resolution should be moved to PersistentPreRun after flag parsing to correctly respect user-provided --directory flags.
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.
Why
Add support for XDG base directory config to stop polluting home directory using
github.com/adrg/xdglibrary while keeping support for legacy~/.pomodoro.This fixes #32
Tested With
Starting with no config directory at all I initialized
~/.pomodoroand used my version to test backwards compatibility:And when using just my version:
Making sure
--directorystill works: