summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-06 03:31:20 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-06 03:31:20 -0400
commite0d6010d3602bfa6a231642816d788d5bc1b6988 (patch)
tree439ec82c7e504946a824964cf3b325aba215d6fc
parent0a36f92a31196451c2d838fd0ae15527e8bbce18 (diff)
simplify
-rw-r--r--Command/Copy.hs2
-rw-r--r--Command/Drop.hs2
-rw-r--r--Command/Find.hs4
-rw-r--r--Command/Get.hs2
-rw-r--r--Command/Move.hs2
-rw-r--r--Seek.hs11
6 files changed, 10 insertions, 13 deletions
diff --git a/Command/Copy.hs b/Command/Copy.hs
index d789d41f6..a9491f56f 100644
--- a/Command/Copy.hs
+++ b/Command/Copy.hs
@@ -16,7 +16,7 @@ def = [withOptions Command.Move.options $ command "copy" paramPaths seek
"copy content of files to/from another repository"]
seek :: [CommandSeek]
-seek = [withField "to" id $ \to -> withField "from" id $ \from ->
+seek = [withField "to" $ \to -> withField "from" $ \from ->
withNumCopies $ \n -> whenAnnexed $ start to from n]
-- A copy is just a move that does not delete the source file.
diff --git a/Command/Drop.hs b/Command/Drop.hs
index f76951f08..3ad407703 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -25,7 +25,7 @@ fromOption :: Option
fromOption = fieldOption ['f'] "from" paramRemote "drop content from a remote"
seek :: [CommandSeek]
-seek = [withField "from" id $ \from -> withNumCopies $ \n ->
+seek = [withField "from" $ \from -> withNumCopies $ \n ->
whenAnnexed $ start from n]
start :: Maybe String -> Maybe Int -> FilePath -> (Key, Backend) -> CommandStart
diff --git a/Command/Find.hs b/Command/Find.hs
index eb0267c14..bc7f200c2 100644
--- a/Command/Find.hs
+++ b/Command/Find.hs
@@ -30,8 +30,8 @@ formatOption :: Option
formatOption = fieldOption [] "format" paramFormat "control format of output"
seek :: [CommandSeek]
-seek = [withField "format" formatconverter $ \f ->
- withFilesInGit $ whenAnnexed $ start f]
+seek = [withField "format" $ \f ->
+ withFilesInGit $ whenAnnexed $ start $ formatconverter f]
where
formatconverter = maybe Nothing (Just . Utility.Format.gen)
diff --git a/Command/Get.hs b/Command/Get.hs
index 4a50fe3fe..c3a6630ce 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -18,7 +18,7 @@ def = [withOptions [Command.Move.fromOption] $ command "get" paramPaths seek
"make content of annexed files available"]
seek :: [CommandSeek]
-seek = [withField "from" id $ \from -> withNumCopies $ \n ->
+seek = [withField "from" $ \from -> withNumCopies $ \n ->
whenAnnexed $ start from n]
start :: Maybe String -> Maybe Int -> FilePath -> (Key, Backend) -> CommandStart
diff --git a/Command/Move.hs b/Command/Move.hs
index 66a0c1660..b6a72bf6b 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -29,7 +29,7 @@ options :: [Option]
options = [fromOption, toOption]
seek :: [CommandSeek]
-seek = [withField "to" id $ \to -> withField "from" id $ \from ->
+seek = [withField "to" $ \to -> withField "from" $ \from ->
withFilesInGit $ whenAnnexed $ start to from True]
start :: Maybe String -> Maybe String -> Bool -> FilePath -> (Key, Backend) -> CommandStart
diff --git a/Seek.hs b/Seek.hs
index af074c7c5..2c121bd96 100644
--- a/Seek.hs
+++ b/Seek.hs
@@ -87,13 +87,10 @@ withKeys a params = return $ map (a . parse) params
where
parse p = fromMaybe (error "bad key") $ readKey p
-{- Modifies a seek action using the value of a field, 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 :: String -> (Maybe String -> a) -> (a -> CommandSeek) -> CommandSeek
-withField field converter a ps = do
- f <- converter <$> Annex.getField field
+{- Feeds the value of a field to a seek action. -}
+withField :: String -> (Maybe String -> CommandSeek) -> CommandSeek
+withField field a ps = do
+ f <- Annex.getField field
a f ps
withNothing :: CommandStart -> CommandSeek