git-annex/Command/Watch.hs
Joey Hess 3ee44cf8fe add assistant command
like watch, but more magic
2012-06-22 13:04:03 -04:00

38 lines
956 B
Haskell

{- git-annex watch command
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Watch where
import Common.Annex
import Assistant
import Command
import Option
def :: [Command]
def = [withOptions [foregroundOption, stopOption] $
command "watch" paramNothing seek "watch for changes"]
mkSeek :: Bool -> [CommandSeek]
mkSeek assistant = [withFlag stopOption $ \stopdaemon ->
withFlag foregroundOption $ \foreground ->
withNothing $ start assistant foreground stopdaemon]
seek :: [CommandSeek]
seek = mkSeek False
foregroundOption :: Option
foregroundOption = Option.flag [] "foreground" "do not daemonize"
stopOption :: Option
stopOption = Option.flag [] "stop" "stop daemon"
start :: Bool -> Bool -> Bool -> CommandStart
start assistant foreground stopdaemon = notBareRepo $ do
if stopdaemon
then stopDaemon
else startDaemon assistant foreground -- does not return
stop