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:
@@ -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
|
||||||
|
|||||||
+20
-2
@@ -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,14 +141,25 @@ 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"
|
||||||
|
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 $
|
hPutStrLn stderr $
|
||||||
"Watching "
|
"Watching "
|
||||||
<> show (length (optRepos options))
|
<> show (length repos)
|
||||||
<> " repo(s)"
|
<> " repo(s)"
|
||||||
<> " (debounce: "
|
<> " (debounce: "
|
||||||
<> show (optDebounceMs options)
|
<> show (optDebounceMs options)
|
||||||
<> "ms)"
|
<> "ms)"
|
||||||
mapM_ (\r -> hPutStrLn stderr (" - " <> rcPath r)) (optRepos options)
|
mapM_ (\r -> hPutStrLn stderr (" - " <> rcPath r)) repos
|
||||||
runConverge options
|
runConverge options
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user