diff options
author | Joey Hess <joey@kitenet.net> | 2011-09-15 16:24:47 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-09-15 16:24:47 -0400 |
commit | 456b45b9b3982d9440a43ec014635dee15066f0e (patch) | |
tree | 18760407864d501595b0cf89de00c755a0105931 /Command.hs | |
parent | d036cd590f5c3c4edcd025effcf57c3d16886559 (diff) |
move annex.numcopies parsing into withNumCopies
Diffstat (limited to 'Command.hs')
-rw-r--r-- | Command.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Command.hs b/Command.hs index bcc05c03c..05b215ec2 100644 --- a/Command.hs +++ b/Command.hs @@ -59,9 +59,6 @@ type CommandStartKey = Key -> CommandStart type BackendFile = (FilePath, Maybe (Backend Annex)) type CommandSeekBackendFiles = CommandStartBackendFile -> CommandSeek type CommandStartBackendFile = BackendFile -> CommandStart -type AttrFile = (FilePath, String) -type CommandSeekAttrFiles = CommandStartAttrFile -> CommandSeek -type CommandStartAttrFile = AttrFile -> CommandStart type CommandSeekNothing = CommandStart -> CommandSeek type CommandStartNothing = CommandStart @@ -129,14 +126,18 @@ withFilesInGit a params = do repo <- Annex.gitRepo files <- liftIO $ runPreserveOrder (LsFiles.inRepo repo) params liftM (map a) $ filterFiles files -withAttrFilesInGit :: String -> CommandSeekAttrFiles +withAttrFilesInGit :: String -> ((FilePath, String) -> CommandStart) -> CommandSeek withAttrFilesInGit attr a params = do repo <- Annex.gitRepo files <- liftIO $ runPreserveOrder (LsFiles.inRepo repo) params files' <- filterFiles files liftM (map a) $ liftIO $ Git.checkAttr repo attr files' -withNumCopies :: CommandSeekAttrFiles -withNumCopies = withAttrFilesInGit "annex.numcopies" +withNumCopies :: (FilePath -> Maybe Int -> CommandStart) -> CommandSeek +withNumCopies a params = withAttrFilesInGit "annex.numcopies" go params + where + go (file, v) = do + let numcopies = readMaybe v + a file numcopies withBackendFilesInGit :: CommandSeekBackendFiles withBackendFilesInGit a params = do repo <- Annex.gitRepo |