summaryrefslogtreecommitdiff
path: root/Seek.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-06 21:27:42 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-06 21:32:08 -0400
commit8e7de0104702d59e327694451303e8fbe53c9ea5 (patch)
treed88304288cf83e39984df73410e1a9836217d888 /Seek.hs
parent539f8c6f144e7fa9cb76f34c06417e3c13ff3420 (diff)
log --before=date
Diffstat (limited to 'Seek.hs')
-rw-r--r--Seek.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/Seek.hs b/Seek.hs
index fdb117de0..59a85be88 100644
--- a/Seek.hs
+++ b/Seek.hs
@@ -88,14 +88,18 @@ withKeys a params = return $ map (a . parse) params
where
parse p = fromMaybe (error "bad key") $ readKey p
+withValue :: Annex v -> (v -> CommandSeek) -> CommandSeek
+withValue v a params = do
+ r <- v
+ a r params
+
{- Modifies a seek action using the value of a field option, which is fed into
- a conversion function, and then is passed into the seek action.
- This ensures that the conversion function only runs once.
-}
withField :: Option -> (Maybe String -> Annex a) -> (a -> CommandSeek) -> CommandSeek
-withField option converter a ps = do
- f <- converter =<< Annex.getField (Option.name option)
- a f ps
+withField option converter = withValue $
+ converter =<< Annex.getField (Option.name option)
withNothing :: CommandStart -> CommandSeek
withNothing a [] = return [a]