From 13a0cd1055b34a93e06b429ca75492ceb8ca1434 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 9 Jul 2025 12:38:32 +0300 Subject: feat: add --batch-run flag for weekly automated sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add --batch-run flag that enables --full and --showcase - Implement state management to track last batch run timestamp - Enforce one-week minimum interval between batch runs - Save state to .gitsyncer-state.json in work directory - Show state file location in output messages - Bump version to 0.5.0 This feature enables automated weekly full synchronization from cron or shell scripts while preventing excessive API usage. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- internal/cli/flags.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'internal/cli/flags.go') diff --git a/internal/cli/flags.go b/internal/cli/flags.go index 7640398..3a9990f 100644 --- a/internal/cli/flags.go +++ b/internal/cli/flags.go @@ -4,6 +4,8 @@ import ( "flag" "os" "path/filepath" + + "codeberg.org/snonux/gitsyncer/internal/state" ) // Flags holds all command-line flag values @@ -27,6 +29,11 @@ type Flags struct { Backup bool Showcase bool Force bool + BatchRun bool + + // Internal fields for batch run state management (not set by flags) + BatchRunStateManager *state.Manager + BatchRunState *state.State } // ParseFlags parses command-line flags and returns the flags struct @@ -54,6 +61,7 @@ func ParseFlags() *Flags { flag.BoolVar(&f.Backup, "backup", false, "enable syncing to backup locations") flag.BoolVar(&f.Showcase, "showcase", false, "generate project showcase using Claude after syncing") flag.BoolVar(&f.Force, "force", false, "force regeneration of cached data") + flag.BoolVar(&f.BatchRun, "batch-run", false, "enable --full and --showcase (runs only once per week)") flag.Parse() @@ -76,5 +84,16 @@ func ParseFlags() *Flags { f.CreateCodebergRepos = true } + // Handle --batch-run flag by enabling --full and --showcase + if f.BatchRun { + f.FullSync = true + f.Showcase = true + // Since we set FullSync, it will trigger the above logic too + f.SyncCodebergPublic = true + f.SyncGitHubPublic = true + f.CreateGitHubRepos = true + f.CreateCodebergRepos = true + } + return f } \ No newline at end of file -- cgit v1.2.3