git-annex/Command/Ungroup.hs
Joey Hess 53526136e8
move commandAction out of CmdLine.Seek
This is groundwork for nested seek loops, eg seeking over all files and
then performing commandActions on a list of remotes, which can be done
concurrently.

This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.
2018-10-01 14:12:06 -04:00

34 lines
791 B
Haskell

{- git-annex command
-
- Copyright 2012 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Ungroup where
import Command
import qualified Remote
import Logs.Group
import Types.Group
import qualified Data.Set as S
cmd :: Command
cmd = command "ungroup" SectionSetup "remove a repository from a group"
(paramPair paramRemote paramDesc) (withParams seek)
seek :: CmdParams -> CommandSeek
seek = withWords (commandAction . start)
start :: [String] -> CommandStart
start (name:g:[]) = do
showStart' "ungroup" (Just name)
u <- Remote.nameToUUID name
next $ perform u g
start _ = giveup "Specify a repository and a group."
perform :: UUID -> Group -> CommandPerform
perform uuid g = do
groupChange uuid (S.delete g)
next $ return True