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:
+27
-9
@@ -22,6 +22,8 @@ data CliArgs = CliArgs
|
||||
-- ^ Log level override.
|
||||
, cliLogFile :: !(Maybe FilePath)
|
||||
-- ^ Log file path.
|
||||
, cliSync :: !Bool
|
||||
-- ^ Run a single sync cycle and exit (useful for wake-from-sleep hooks).
|
||||
}
|
||||
|
||||
cliParser :: Parser CliArgs
|
||||
@@ -87,6 +89,11 @@ cliParser =
|
||||
<> 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 =
|
||||
@@ -134,15 +141,26 @@ main = do
|
||||
hPutStrLn stderr ("Using config: " <> path)
|
||||
Nothing ->
|
||||
hPutStrLn stderr "No config file found, using single-repo mode"
|
||||
hPutStrLn stderr $
|
||||
"Watching "
|
||||
<> show (length (optRepos options))
|
||||
<> " repo(s)"
|
||||
<> " (debounce: "
|
||||
<> show (optDebounceMs options)
|
||||
<> "ms)"
|
||||
mapM_ (\r -> hPutStrLn stderr (" - " <> rcPath r)) (optRepos options)
|
||||
runConverge options
|
||||
let repos = optRepos options
|
||||
if cliSync cli
|
||||
then do
|
||||
hPutStrLn stderr $
|
||||
"Syncing "
|
||||
<> show (length repos)
|
||||
<> " repo(s)"
|
||||
mapM_ (\r -> hPutStrLn stderr (" - " <> rcPath r)) repos
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user