summaryrefslogtreecommitdiff
path: root/Command/GroupWanted.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-18 16:04:25 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-18 16:04:35 -0400
commitea2180a6c141411f8ebdd041f065fae54ff2f780 (patch)
treeef19371742d05d8f2562ee49abc20db315983000 /Command/GroupWanted.hs
parent56e6d094aafd0df4b6e9f7abb83ff87b352aead5 (diff)
required: New command, like wanted, but for required content.
Also refactored some code to reduce duplication.
Diffstat (limited to 'Command/GroupWanted.hs')
-rw-r--r--Command/GroupWanted.hs19
1 files changed, 3 insertions, 16 deletions
diff --git a/Command/GroupWanted.hs b/Command/GroupWanted.hs
index 859a39c1b..8fff47013 100644
--- a/Command/GroupWanted.hs
+++ b/Command/GroupWanted.hs
@@ -13,6 +13,7 @@ import Command
import Logs.PreferredContent
import Types.Messages
import Types.Group
+import Command.Wanted (performGet, performSet)
import qualified Data.Map as M
@@ -24,22 +25,8 @@ seek :: CommandSeek
seek = withWords start
start :: [String] -> CommandStart
-start (g:[]) = next $ performGet g
+start (g:[]) = next $ performGet groupPreferredContentMapRaw g
start (g:expr:[]) = do
showStart "groupwanted" g
- next $ performSet g expr
+ next $ performSet groupPreferredContentSet expr g
start _ = error "Specify a group."
-
-performGet :: Group -> CommandPerform
-performGet g = do
- Annex.setOutput QuietOutput
- m <- groupPreferredContentMapRaw
- liftIO $ putStrLn $ fromMaybe "" $ M.lookup g m
- next $ return True
-
-performSet :: Group -> String -> CommandPerform
-performSet g expr = case checkPreferredContentExpression expr of
- Just e -> error $ "Parse error: " ++ e
- Nothing -> do
- groupPreferredContentSet g expr
- next $ return True