Revert "simplify"

This reverts commit e0d6010d36.
This commit is contained in:
Joey Hess 2012-01-06 17:50:58 -04:00
parent e0d6010d36
commit bc59da7250
6 changed files with 13 additions and 10 deletions

View file

@ -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" $ \to -> withField "from" $ \from ->
seek = [withField "to" id $ \to -> withField "from" id $ \from ->
withNumCopies $ \n -> whenAnnexed $ start to from n]
-- A copy is just a move that does not delete the source file.

View file

@ -25,7 +25,7 @@ fromOption :: Option
fromOption = fieldOption ['f'] "from" paramRemote "drop content from a remote"
seek :: [CommandSeek]
seek = [withField "from" $ \from -> withNumCopies $ \n ->
seek = [withField "from" id $ \from -> withNumCopies $ \n ->
whenAnnexed $ start from n]
start :: Maybe String -> Maybe Int -> FilePath -> (Key, Backend) -> CommandStart

View file

@ -30,8 +30,8 @@ formatOption :: Option
formatOption = fieldOption [] "format" paramFormat "control format of output"
seek :: [CommandSeek]
seek = [withField "format" $ \f ->
withFilesInGit $ whenAnnexed $ start $ formatconverter f]
seek = [withField "format" formatconverter $ \f ->
withFilesInGit $ whenAnnexed $ start f]
where
formatconverter = maybe Nothing (Just . Utility.Format.gen)

View file

@ -18,7 +18,7 @@ def = [withOptions [Command.Move.fromOption] $ command "get" paramPaths seek
"make content of annexed files available"]
seek :: [CommandSeek]
seek = [withField "from" $ \from -> withNumCopies $ \n ->
seek = [withField "from" id $ \from -> withNumCopies $ \n ->
whenAnnexed $ start from n]
start :: Maybe String -> Maybe Int -> FilePath -> (Key, Backend) -> CommandStart

View file

@ -29,7 +29,7 @@ options :: [Option]
options = [fromOption, toOption]
seek :: [CommandSeek]
seek = [withField "to" $ \to -> withField "from" $ \from ->
seek = [withField "to" id $ \to -> withField "from" id $ \from ->
withFilesInGit $ whenAnnexed $ start to from True]
start :: Maybe String -> Maybe String -> Bool -> FilePath -> (Key, Backend) -> CommandStart

11
Seek.hs
View file

@ -87,10 +87,13 @@ withKeys a params = return $ map (a . parse) params
where
parse p = fromMaybe (error "bad key") $ readKey p
{- 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
{- 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
a f ps
withNothing :: CommandStart -> CommandSeek