summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-13 21:26:16 +0300
committerPaul Buetow <paul@buetow.org>2025-07-13 21:26:16 +0300
commit735cbc11e1a3e103a69c03390b5f40ecc810dc9c (patch)
tree0622c72f3c9d3ea2f8c9e9fd39d59a68b87d6351 /internal
parentfa5ef028ec9a7af801710eed190057d3b3c172f0 (diff)
fix: update default config path to follow XDG Base Directory spec
- Change default config from ~/.gitsyncer.json to ~/.config/gitsyncer/config - Update all documentation and help text to reflect new path - LoadConfig still checks common locations for backward compatibility: - ./gitsyncer.json - ~/.config/gitsyncer/config (new default) - ~/.gitsyncer.json This follows the XDG Base Directory specification for better organization of configuration files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/cli/handlers.go4
-rw-r--r--internal/cmd/root.go2
-rw-r--r--internal/cmd/test.go2
-rw-r--r--internal/config/config.go3
4 files changed, 6 insertions, 5 deletions
diff --git a/internal/cli/handlers.go b/internal/cli/handlers.go
index 02df7ae..44c64c6 100644
--- a/internal/cli/handlers.go
+++ b/internal/cli/handlers.go
@@ -69,7 +69,7 @@ func findDefaultConfigPath() string {
// Check common config locations
configLocations := []string{
filepath.Join(".", "gitsyncer.json"),
- filepath.Join(home, ".config", "gitsyncer", "config.json"),
+ filepath.Join(home, ".config", "gitsyncer", "config"),
filepath.Join(home, ".gitsyncer.json"),
}
@@ -88,7 +88,7 @@ func ShowConfigHelp() {
fmt.Println("No configuration file found. Please create one of:")
fmt.Printf(" - ./gitsyncer.json\n")
- fmt.Printf(" - %s/.config/gitsyncer/config.json\n", home)
+ fmt.Printf(" - %s/.config/gitsyncer/config\n", home)
fmt.Printf(" - %s/.gitsyncer.json\n", home)
fmt.Println("\nOr specify a config file with --config flag")
fmt.Println("\nExample configuration:")
diff --git a/internal/cmd/root.go b/internal/cmd/root.go
index 04ea6dd..927a9b8 100644
--- a/internal/cmd/root.go
+++ b/internal/cmd/root.go
@@ -53,7 +53,7 @@ func Execute() {
func init() {
// Global flags
- rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "configuration file (default: ~/.gitsyncer.json)")
+ rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "configuration file (default: ~/.config/gitsyncer/config)")
// Set default work directory
home, err := os.UserHomeDir()
diff --git a/internal/cmd/test.go b/internal/cmd/test.go
index 0590719..2c50112 100644
--- a/internal/cmd/test.go
+++ b/internal/cmd/test.go
@@ -44,7 +44,7 @@ var testConfigCmd = &cobra.Command{
gitsyncer test config
# Test specific config file
- gitsyncer test config -c ~/my-gitsyncer.json`,
+ gitsyncer test config -c ~/my-config.json`,
Run: func(cmd *cobra.Command, args []string) {
// Try to load and validate config
cfg, err := config.Load(cfgFile)
diff --git a/internal/config/config.go b/internal/config/config.go
index 799c792..a141c81 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -34,7 +34,8 @@ func Load(path string) (*Config, error) {
if err != nil {
return nil, fmt.Errorf("failed to get home directory: %w", err)
}
- path = filepath.Join(home, ".gitsyncer.json")
+ // Use XDG config directory
+ path = filepath.Join(home, ".config", "gitsyncer", "config")
} else if len(path) >= 2 && path[:2] == "~/" {
// Expand home directory if needed
home, err := os.UserHomeDir()