Skip to content

Move config file default path to os.UserConfigDir()#229

Merged
kordianbruck merged 3 commits intomasterfrom
copilot/move-config-file-to-user-config-dir
Apr 11, 2026
Merged

Move config file default path to os.UserConfigDir()#229
kordianbruck merged 3 commits intomasterfrom
copilot/move-config-file-to-user-config-dir

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 11, 2026

Motivation and Context

Config defaulted to $HOME/.wegorc on all platforms, ignoring XDG and OS-native config directories.

Description

Adds resolveConfigPath() in main.go that resolves the config path with the following priority:

  1. $WEGORC — explicit override, unchanged behavior
  2. os.UserConfigDir()/wego/wegorc — XDG on Linux (~/.config/wego/wegorc), ~/Library/Application Support/wego/wegorc on macOS, %AppData%\wego\wegorc on Windows — used if it already exists
  3. $HOME/.wegorc — legacy fallback for backward compatibility, used if it exists
  4. os.UserConfigDir()/wego/wegorc — new install default; parent directory is MkdirAll'd automatically

Since ingo determines its path via the $WEGORC env var, the resolved path is injected via os.Setenv("WEGORC", configPath) before calling ingo.Parse("wego").

Updated man page strings and README.md to reflect the new resolution order.

Steps for Testing

  • Fresh install (no existing config): run wego; confirm config is created at $XDG_CONFIG_HOME/wego/wegorc (e.g. ~/.config/wego/wegorc on Linux).
  • Legacy migration: place an existing config at ~/.wegorc; run wego and confirm it is picked up without moving the file.
  • Explicit override: set WEGORC=/tmp/test.rc and run wego; confirm that path is used.
  • XDG config present: place a config at ~/.config/wego/wegorc alongside a ~/.wegorc; confirm the XDG path takes precedence.

Screenshots

N/A — CLI tool, no UI changes.

Agent-Logs-Url: https://github.com/schachmat/wego/sessions/5248c0c9-512b-40a6-8353-fc1205c9a659

Co-authored-by: kordianbruck <298860+kordianbruck@users.noreply.github.com>
Copilot AI changed the title [WIP] Move config file default path to os.UserConfigDir Move config file default path to os.UserConfigDir() Apr 11, 2026
Copilot AI requested a review from kordianbruck April 11, 2026 22:45
@kordianbruck kordianbruck marked this pull request as ready for review April 11, 2026 23:12
@kordianbruck kordianbruck merged commit a7739fd into master Apr 11, 2026
2 checks passed
@kordianbruck kordianbruck deleted the copilot/move-config-file-to-user-config-dir branch April 11, 2026 23:17
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.

Move config file default path to os.UserConfigDir()

2 participants