summaryrefslogtreecommitdiff
path: root/internal/cli/flags.go
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 /internal/cli/flags.go
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 'internal/cli/flags.go')
-rw-r--r--internal/cli/flags.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/internal/cli/flags.go b/internal/cli/flags.go
index c0320c5..9b8afdc 100644
--- a/internal/cli/flags.go
+++ b/internal/cli/flags.go
@@ -1,6 +1,10 @@
package cli
-import "flag"
+import (
+ "flag"
+ "os"
+ "path/filepath"
+)
// Flags holds all command-line flag values
type Flags struct {
@@ -38,11 +42,22 @@ func ParseFlags() *Flags {
flag.BoolVar(&f.CreateGitHubRepos, "create-github-repos", false, "automatically create missing GitHub repositories")
flag.BoolVar(&f.CreateCodebergRepos, "create-codeberg-repos", false, "automatically create missing Codeberg repositories")
flag.BoolVar(&f.DryRun, "dry-run", false, "show what would be synced without actually syncing")
- flag.StringVar(&f.WorkDir, "work-dir", ".gitsyncer-work", "working directory for cloning repositories")
+ flag.StringVar(&f.WorkDir, "work-dir", "", "working directory for cloning repositories (default: ~/git/gitsyncer-workdir)")
flag.BoolVar(&f.TestGitHubToken, "test-github-token", false, "test GitHub token authentication")
flag.Parse()
+ // Set default WorkDir if not provided
+ if f.WorkDir == "" {
+ home, err := os.UserHomeDir()
+ if err == nil {
+ f.WorkDir = filepath.Join(home, "git", "gitsyncer-workdir")
+ } else {
+ // Fallback if we can't get home directory
+ f.WorkDir = ".gitsyncer-work"
+ }
+ }
+
// Handle --full flag by enabling all sync operations
if f.FullSync {
f.SyncCodebergPublic = true