2012-10-01 19:12:04 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2012 Joey Hess <id@joeyh.name>
|
2012-10-01 19:12:04 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Group where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import qualified Remote
|
|
|
|
import Logs.Group
|
|
|
|
import Types.Group
|
|
|
|
|
|
|
|
import qualified Data.Set as S
|
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2017-02-16 17:24:16 +00:00
|
|
|
cmd = noMessages $ command "group" SectionSetup "add a repository to a group"
|
2015-07-08 19:08:02 +00:00
|
|
|
(paramPair paramRemote paramDesc) (withParams seek)
|
2012-10-01 19:12:04 +00:00
|
|
|
|
2015-07-08 19:08:02 +00:00
|
|
|
seek :: CmdParams -> CommandSeek
|
2018-10-01 18:12:06 +00:00
|
|
|
seek = withWords (commandAction . start)
|
2012-10-01 19:12:04 +00:00
|
|
|
|
|
|
|
start :: [String] -> CommandStart
|
|
|
|
start (name:g:[]) = do
|
2017-02-16 17:24:16 +00:00
|
|
|
allowMessages
|
2017-11-28 18:40:26 +00:00
|
|
|
showStart' "group" (Just name)
|
2012-10-01 19:12:04 +00:00
|
|
|
u <- Remote.nameToUUID name
|
2014-05-16 18:43:40 +00:00
|
|
|
next $ setGroup u g
|
|
|
|
start (name:[]) = do
|
|
|
|
u <- Remote.nameToUUID name
|
2017-02-16 17:24:16 +00:00
|
|
|
liftIO . putStrLn . unwords . S.toList =<< lookupGroups u
|
2014-05-16 18:43:40 +00:00
|
|
|
stop
|
2016-11-16 01:29:54 +00:00
|
|
|
start _ = giveup "Specify a repository and a group."
|
2012-10-01 19:12:04 +00:00
|
|
|
|
2014-05-16 18:43:40 +00:00
|
|
|
setGroup :: UUID -> Group -> CommandPerform
|
|
|
|
setGroup uuid g = do
|
2012-10-01 19:17:21 +00:00
|
|
|
groupChange uuid (S.insert g)
|
2012-10-01 19:12:04 +00:00
|
|
|
next $ return True
|