git-annex/Command/Watch.hs

39 lines
905 B
Haskell
Raw Normal View History

{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns #-}
2012-06-13 12:36:33 -04:00
{- git-annex watch command
2012-06-11 15:41:26 -04: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 12:36:33 -04:00
import Assistant
import Command
2012-06-11 00:39:09 -04:00
import Option
def :: [Command]
2012-06-11 02:01:20 -04:00
def = [withOptions [foregroundOption, stopOption] $
2012-06-12 19:36:11 -04:00
command "watch" paramNothing seek "watch for changes"]
seek :: [CommandSeek]
2012-06-11 02:01:20 -04:00
seek = [withFlag stopOption $ \stopdaemon ->
withFlag foregroundOption $ \foreground ->
withNothing $ start foreground stopdaemon]
2012-06-11 00:39:09 -04:00
foregroundOption :: Option
foregroundOption = Option.flag [] "foreground" "do not daemonize"
2012-06-11 02:01:20 -04:00
stopOption :: Option
stopOption = Option.flag [] "stop" "stop daemon"
start :: Bool -> Bool -> CommandStart
start foreground stopdaemon = notBareRepo $ do
if stopdaemon
2012-06-13 12:36:33 -04:00
then stopDaemon
else startDaemon foreground -- does not return
2012-06-10 17:40:35 -04:00
stop