summaryrefslogtreecommitdiff
path: root/Command/Add.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-19 17:46:46 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-19 17:48:42 -0400
commit90b1891e1e2be29ae122a2613a462959f3c32611 (patch)
tree306af03e34b7d219d178a3f0d16975b8de5ca58a /Command/Add.hs
parent8d1ac05755f970f0ec9553c9a7680a5512726c28 (diff)
add --batch
Diffstat (limited to 'Command/Add.hs')
-rw-r--r--Command/Add.hs20
1 files changed, 14 insertions, 6 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 0dea0a7b7..f2fcd2fb1 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -22,6 +22,7 @@ import Annex.FileMatcher
import Annex.Version
import qualified Database.Keys
import Types.Key
+import CmdLine.Batch
cmd :: Command
cmd = notBareRepo $ withGlobalOptions (jobsOption : jsonOption : fileMatchingOptions) $
@@ -31,6 +32,7 @@ cmd = notBareRepo $ withGlobalOptions (jobsOption : jsonOption : fileMatchingOpt
data AddOptions = AddOptions
{ addThese :: CmdParams
, includeDotFiles :: Bool
+ , batchOption :: BatchMode
}
optParser :: CmdParamsDesc -> Parser AddOptions
@@ -40,6 +42,7 @@ optParser desc = AddOptions
( long "include-dotfiles"
<> help "don't skip dotfiles"
)
+ <*> parseBatchOption
{- Add acts on both files not checked into git yet, and unlocked files.
-
@@ -47,15 +50,20 @@ optParser desc = AddOptions
seek :: AddOptions -> CommandSeek
seek o = allowConcurrentOutput $ do
matcher <- largeFilesMatcher
- let go a = flip a (addThese o) $ \file -> ifM (checkFileMatcher matcher file <||> Annex.getState Annex.force)
+ let gofile file = ifM (checkFileMatcher matcher file <||> Annex.getState Annex.force)
( start file
, startSmall file
)
- go $ withFilesNotInGit (not $ includeDotFiles o)
- ifM (versionSupportsUnlockedPointers <||> isDirect)
- ( go withFilesMaybeModified
- , go withFilesOldUnlocked
- )
+ case batchOption o of
+ Batch -> batchInput Right $
+ batchCommandAction . gofile
+ NoBatch -> do
+ let go a = a gofile (addThese o)
+ go (withFilesNotInGit (not $ includeDotFiles o))
+ ifM (versionSupportsUnlockedPointers <||> isDirect)
+ ( go withFilesMaybeModified
+ , go withFilesOldUnlocked
+ )
{- Pass file off to git-add. -}
startSmall :: FilePath -> CommandStart