add assistant command
like watch, but more magic
This commit is contained in:
parent
cf9bf920e8
commit
3ee44cf8fe
5 changed files with 36 additions and 12 deletions
|
@ -55,10 +55,10 @@ import Utility.LogFile
|
||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
|
|
||||||
startDaemon :: Bool -> Annex ()
|
startDaemon :: Bool -> Bool -> Annex ()
|
||||||
startDaemon foreground
|
startDaemon assistant foreground
|
||||||
| foreground = do
|
| foreground = do
|
||||||
showStart "watch" "."
|
showStart (if assistant then "assistant" else "watch") "."
|
||||||
go id
|
go id
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
logfd <- liftIO . openLog =<< fromRepo gitAnnexLogFile
|
logfd <- liftIO . openLog =<< fromRepo gitAnnexLogFile
|
||||||
|
|
18
Command/Assistant.hs
Normal file
18
Command/Assistant.hs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{- git-annex assistant
|
||||||
|
-
|
||||||
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||||
|
-
|
||||||
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Command.Assistant where
|
||||||
|
|
||||||
|
import Command
|
||||||
|
import qualified Command.Watch
|
||||||
|
|
||||||
|
def :: [Command]
|
||||||
|
def = [withOptions [Command.Watch.foregroundOption, Command.Watch.stopOption] $
|
||||||
|
command "assistant" paramNothing seek "automatically handle changes"]
|
||||||
|
|
||||||
|
seek :: [CommandSeek]
|
||||||
|
seek = Command.Watch.mkSeek True
|
|
@ -1,6 +1,3 @@
|
||||||
{-# LANGUAGE CPP #-}
|
|
||||||
{-# LANGUAGE BangPatterns #-}
|
|
||||||
|
|
||||||
{- git-annex watch command
|
{- git-annex watch command
|
||||||
-
|
-
|
||||||
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||||
|
@ -19,10 +16,13 @@ def :: [Command]
|
||||||
def = [withOptions [foregroundOption, stopOption] $
|
def = [withOptions [foregroundOption, stopOption] $
|
||||||
command "watch" paramNothing seek "watch for changes"]
|
command "watch" paramNothing seek "watch for changes"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
mkSeek :: Bool -> [CommandSeek]
|
||||||
seek = [withFlag stopOption $ \stopdaemon ->
|
mkSeek assistant = [withFlag stopOption $ \stopdaemon ->
|
||||||
withFlag foregroundOption $ \foreground ->
|
withFlag foregroundOption $ \foreground ->
|
||||||
withNothing $ start foreground stopdaemon]
|
withNothing $ start assistant foreground stopdaemon]
|
||||||
|
|
||||||
|
seek :: [CommandSeek]
|
||||||
|
seek = mkSeek False
|
||||||
|
|
||||||
foregroundOption :: Option
|
foregroundOption :: Option
|
||||||
foregroundOption = Option.flag [] "foreground" "do not daemonize"
|
foregroundOption = Option.flag [] "foreground" "do not daemonize"
|
||||||
|
@ -30,9 +30,9 @@ foregroundOption = Option.flag [] "foreground" "do not daemonize"
|
||||||
stopOption :: Option
|
stopOption :: Option
|
||||||
stopOption = Option.flag [] "stop" "stop daemon"
|
stopOption = Option.flag [] "stop" "stop daemon"
|
||||||
|
|
||||||
start :: Bool -> Bool -> CommandStart
|
start :: Bool -> Bool -> Bool -> CommandStart
|
||||||
start foreground stopdaemon = notBareRepo $ do
|
start assistant foreground stopdaemon = notBareRepo $ do
|
||||||
if stopdaemon
|
if stopdaemon
|
||||||
then stopDaemon
|
then stopDaemon
|
||||||
else startDaemon foreground -- does not return
|
else startDaemon assistant foreground -- does not return
|
||||||
stop
|
stop
|
||||||
|
|
|
@ -59,6 +59,7 @@ import qualified Command.Map
|
||||||
import qualified Command.Upgrade
|
import qualified Command.Upgrade
|
||||||
import qualified Command.Version
|
import qualified Command.Version
|
||||||
import qualified Command.Watch
|
import qualified Command.Watch
|
||||||
|
import qualified Command.Assistant
|
||||||
|
|
||||||
cmds :: [Command]
|
cmds :: [Command]
|
||||||
cmds = concat
|
cmds = concat
|
||||||
|
@ -101,6 +102,7 @@ cmds = concat
|
||||||
, Command.Upgrade.def
|
, Command.Upgrade.def
|
||||||
, Command.Version.def
|
, Command.Version.def
|
||||||
, Command.Watch.def
|
, Command.Watch.def
|
||||||
|
, Command.Assistant.def
|
||||||
]
|
]
|
||||||
|
|
||||||
options :: [Option]
|
options :: [Option]
|
||||||
|
|
|
@ -180,6 +180,10 @@ subdirectories).
|
||||||
To not daemonize, run with --foreground ; to stop a running daemon,
|
To not daemonize, run with --foreground ; to stop a running daemon,
|
||||||
run with --stop
|
run with --stop
|
||||||
|
|
||||||
|
* assistant
|
||||||
|
|
||||||
|
Like watch, but also automatically syncs changes to other remotes.
|
||||||
|
|
||||||
# REPOSITORY SETUP COMMANDS
|
# REPOSITORY SETUP COMMANDS
|
||||||
|
|
||||||
* init [description]
|
* init [description]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue