parent
e0d6010d36
commit
bc59da7250
6 changed files with 13 additions and 10 deletions
|
@ -16,7 +16,7 @@ def = [withOptions Command.Move.options $ command "copy" paramPaths seek
|
||||||
"copy content of files to/from another repository"]
|
"copy content of files to/from another repository"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
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]
|
withNumCopies $ \n -> whenAnnexed $ start to from n]
|
||||||
|
|
||||||
-- A copy is just a move that does not delete the source file.
|
-- A copy is just a move that does not delete the source file.
|
||||||
|
|
|
@ -25,7 +25,7 @@ fromOption :: Option
|
||||||
fromOption = fieldOption ['f'] "from" paramRemote "drop content from a remote"
|
fromOption = fieldOption ['f'] "from" paramRemote "drop content from a remote"
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withField "from" $ \from -> withNumCopies $ \n ->
|
seek = [withField "from" id $ \from -> withNumCopies $ \n ->
|
||||||
whenAnnexed $ start from n]
|
whenAnnexed $ start from n]
|
||||||
|
|
||||||
start :: Maybe String -> Maybe Int -> FilePath -> (Key, Backend) -> CommandStart
|
start :: Maybe String -> Maybe Int -> FilePath -> (Key, Backend) -> CommandStart
|
||||||
|
|
|
@ -30,8 +30,8 @@ formatOption :: Option
|
||||||
formatOption = fieldOption [] "format" paramFormat "control format of output"
|
formatOption = fieldOption [] "format" paramFormat "control format of output"
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withField "format" $ \f ->
|
seek = [withField "format" formatconverter $ \f ->
|
||||||
withFilesInGit $ whenAnnexed $ start $ formatconverter f]
|
withFilesInGit $ whenAnnexed $ start f]
|
||||||
where
|
where
|
||||||
formatconverter = maybe Nothing (Just . Utility.Format.gen)
|
formatconverter = maybe Nothing (Just . Utility.Format.gen)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ def = [withOptions [Command.Move.fromOption] $ command "get" paramPaths seek
|
||||||
"make content of annexed files available"]
|
"make content of annexed files available"]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withField "from" $ \from -> withNumCopies $ \n ->
|
seek = [withField "from" id $ \from -> withNumCopies $ \n ->
|
||||||
whenAnnexed $ start from n]
|
whenAnnexed $ start from n]
|
||||||
|
|
||||||
start :: Maybe String -> Maybe Int -> FilePath -> (Key, Backend) -> CommandStart
|
start :: Maybe String -> Maybe Int -> FilePath -> (Key, Backend) -> CommandStart
|
||||||
|
|
|
@ -29,7 +29,7 @@ options :: [Option]
|
||||||
options = [fromOption, toOption]
|
options = [fromOption, toOption]
|
||||||
|
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek = [withField "to" $ \to -> withField "from" $ \from ->
|
seek = [withField "to" id $ \to -> withField "from" id $ \from ->
|
||||||
withFilesInGit $ whenAnnexed $ start to from True]
|
withFilesInGit $ whenAnnexed $ start to from True]
|
||||||
|
|
||||||
start :: Maybe String -> Maybe String -> Bool -> FilePath -> (Key, Backend) -> CommandStart
|
start :: Maybe String -> Maybe String -> Bool -> FilePath -> (Key, Backend) -> CommandStart
|
||||||
|
|
11
Seek.hs
11
Seek.hs
|
@ -87,10 +87,13 @@ withKeys a params = return $ map (a . parse) params
|
||||||
where
|
where
|
||||||
parse p = fromMaybe (error "bad key") $ readKey p
|
parse p = fromMaybe (error "bad key") $ readKey p
|
||||||
|
|
||||||
{- Feeds the value of a field to a seek action. -}
|
{- Modifies a seek action using the value of a field, which is fed into
|
||||||
withField :: String -> (Maybe String -> CommandSeek) -> CommandSeek
|
- a conversion function, and then is passed into the seek action.
|
||||||
withField field a ps = do
|
- This ensures that the conversion function only runs once.
|
||||||
f <- Annex.getField field
|
-}
|
||||||
|
withField :: String -> (Maybe String -> a) -> (a -> CommandSeek) -> CommandSeek
|
||||||
|
withField field converter a ps = do
|
||||||
|
f <- converter <$> Annex.getField field
|
||||||
a f ps
|
a f ps
|
||||||
|
|
||||||
withNothing :: CommandStart -> CommandSeek
|
withNothing :: CommandStart -> CommandSeek
|
||||||
|
|
Loading…
Reference in a new issue