git-annex/Command/Watch.hs

36 lines
895 B
Haskell
Raw Normal View History

2012-06-13 16:36:33 +00:00
{- git-annex watch command
2012-06-11 19:41:26 +00:00
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Watch where
import Common.Annex
2012-06-13 16:36:33 +00:00
import Assistant
import Command
2012-06-11 04:39:09 +00:00
import Option
def :: [Command]
2012-06-11 06:01:20 +00:00
def = [withOptions [foregroundOption, stopOption] $
2012-06-12 23:36:11 +00:00
command "watch" paramNothing seek "watch for changes"]
seek :: [CommandSeek]
seek = [withFlag stopOption $ \stopdaemon ->
withFlag foregroundOption $ \foreground ->
withNothing $ start False foreground stopdaemon]
2012-06-11 04:39:09 +00:00
foregroundOption :: Option
foregroundOption = Option.flag [] "foreground" "do not daemonize"
2012-06-11 06:01:20 +00:00
stopOption :: Option
stopOption = Option.flag [] "stop" "stop daemon"
start :: Bool -> Bool -> Bool -> CommandStart
start assistant foreground stopdaemon = notBareRepo $ do
2012-06-11 06:01:20 +00:00
if stopdaemon
2012-06-13 16:36:33 +00:00
then stopDaemon
else startDaemon assistant foreground Nothing -- does not return
2012-06-10 21:40:35 +00:00
stop