summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-25 22:32:56 +0300
committerPaul Buetow <paul@buetow.org>2025-06-25 22:32:56 +0300
commit7c30b68f29049704c7fafed8015169e9c8047e46 (patch)
tree2c3af6da0e87cec553d0fde02aaf04cb8c2a4e01 /cmd
parentaf8ab19f5def6f00081b0a6d1e5b20b76683f720 (diff)
feat: add configurable work directory with default ~/git/gitsyncer-workdir
- Add work_dir field to configuration file - Set default work directory to ~/git/gitsyncer-workdir (avoiding conflict with source repo) - Support home directory expansion (~/) in work_dir config - Command-line --work-dir flag takes precedence over config file - Automatically create work directory if it doesn't exist 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gitsyncer/main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/gitsyncer/main.go b/cmd/gitsyncer/main.go
index 5175a1f..021d4be 100644
--- a/cmd/gitsyncer/main.go
+++ b/cmd/gitsyncer/main.go
@@ -2,6 +2,7 @@ package main
import (
"os"
+ "path/filepath"
"codeberg.org/snonux/gitsyncer/internal/cli"
)
@@ -32,6 +33,15 @@ func main() {
os.Exit(1)
}
+ // Use config WorkDir only if no flag was explicitly provided
+ // We check if WorkDir matches the default we set in ParseFlags
+ home, _ := os.UserHomeDir()
+ defaultWorkDir := filepath.Join(home, "git", "gitsyncer-workdir")
+ if flags.WorkDir == defaultWorkDir && cfg.WorkDir != "" {
+ // User didn't specify --work-dir, so use config value
+ flags.WorkDir = cfg.WorkDir
+ }
+
// Handle list organizations flag
if flags.ListOrgs {
os.Exit(cli.HandleListOrgs(cfg))