Add --sync flag for one-shot sync-and-exit mode
Build / build (push) Failing after 6s

Useful for wake-from-sleep hooks: run 'converge --sync' to commit
any pending changes, pull from remotes, and push, then exit.
Shows 'Syncing N repo(s)' instead of 'Watching N repo(s)'.
This commit is contained in:
2026-05-14 10:34:36 -04:00
parent 97078928fc
commit 477a86c18a
2 changed files with 29 additions and 9 deletions
+2
View File
@@ -16,3 +16,5 @@
## Supports configurable log levels (debug, info, warn, error) ## Supports configurable log levels (debug, info, warn, error)
## Supports logging to a file instead of stderr via --log-file or log_file config ## Supports logging to a file instead of stderr via --log-file or log_file config
## Can notify on pull: per-repo notify_on_pull setting sends a desktop notification when new commits are pulled from the remote ## Can notify on pull: per-repo notify_on_pull setting sends a desktop notification when new commits are pulled from the remote
## --sync / -s flag runs a single sync cycle (commit + pull + push) and exits, useful for wake-from-sleep hooks
+27 -9
View File
@@ -22,6 +22,8 @@ data CliArgs = CliArgs
-- ^ Log level override. -- ^ Log level override.
, cliLogFile :: !(Maybe FilePath) , cliLogFile :: !(Maybe FilePath)
-- ^ Log file path. -- ^ Log file path.
, cliSync :: !Bool
-- ^ Run a single sync cycle and exit (useful for wake-from-sleep hooks).
} }
cliParser :: Parser CliArgs cliParser :: Parser CliArgs
@@ -87,6 +89,11 @@ cliParser =
<> help "Write logs to a file instead of stderr" <> help "Write logs to a file instead of stderr"
) )
) )
<*> switch
( long "sync"
<> short 's'
<> help "Run a single sync cycle (commit + pull + push) and exit"
)
parserInfo :: ParserInfo CliArgs parserInfo :: ParserInfo CliArgs
parserInfo = parserInfo =
@@ -134,15 +141,26 @@ main = do
hPutStrLn stderr ("Using config: " <> path) hPutStrLn stderr ("Using config: " <> path)
Nothing -> Nothing ->
hPutStrLn stderr "No config file found, using single-repo mode" hPutStrLn stderr "No config file found, using single-repo mode"
hPutStrLn stderr $ let repos = optRepos options
"Watching " if cliSync cli
<> show (length (optRepos options)) then do
<> " repo(s)" hPutStrLn stderr $
<> " (debounce: " "Syncing "
<> show (optDebounceMs options) <> show (length repos)
<> "ms)" <> " repo(s)"
mapM_ (\r -> hPutStrLn stderr (" - " <> rcPath r)) (optRepos options) mapM_ (\r -> hPutStrLn stderr (" - " <> rcPath r)) repos
runConverge options logger <- newLogger (optLogLevel options) (optLogFile options)
mapM_ (syncRepo options logger) repos
else do
hPutStrLn stderr $
"Watching "
<> show (length repos)
<> " repo(s)"
<> " (debounce: "
<> show (optDebounceMs options)
<> "ms)"
mapM_ (\r -> hPutStrLn stderr (" - " <> rcPath r)) repos
runConverge options
-- | Apply CLI overrides (debounce, log level, log file) to Options. -- | Apply CLI overrides (debounce, log level, log file) to Options.