summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-08-15 12:39:10 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-08-15 12:39:10 -0400
commit802cecdf36f2575b62c42b105019ea70f3e8aef8 (patch)
tree6f251c57d645bbcbd758632f87858eec06611920 /Command
parentcb91d1539e4f7d935c5106dbf54a7d58b5f297d6 (diff)
move, copy: Support --batch.
Diffstat (limited to 'Command')
-rw-r--r--Command/Copy.hs14
-rw-r--r--Command/Move.hs16
2 files changed, 20 insertions, 10 deletions
diff --git a/Command/Copy.hs b/Command/Copy.hs
index 667f940f0..f071bf2dd 100644
--- a/Command/Copy.hs
+++ b/Command/Copy.hs
@@ -35,11 +35,15 @@ instance DeferredParseClass CopyOptions where
<*> pure (autoMode v)
seek :: CopyOptions -> CommandSeek
-seek o = allowConcurrentOutput $
- withKeyOptions (Command.Move.keyOptions $ moveOptions o) (autoMode o)
- (Command.Move.startKey (moveOptions o) False)
- (withFilesInGit $ whenAnnexed $ start o)
- (Command.Move.moveFiles $ moveOptions o)
+seek o = allowConcurrentOutput $ do
+ let go = whenAnnexed $ start o
+ case Command.Move.batchOption (moveOptions o) of
+ Batch -> batchInput Right (batchCommandAction . go)
+ NoBatch -> withKeyOptions
+ (Command.Move.keyOptions $ moveOptions o) (autoMode o)
+ (Command.Move.startKey (moveOptions o) False)
+ (withFilesInGit go)
+ (Command.Move.moveFiles $ moveOptions o)
{- A copy is just a move that does not delete the source file.
- However, auto mode avoids unnecessary copies, and avoids getting or
diff --git a/Command/Move.hs b/Command/Move.hs
index 6c65b8c2a..74aa430d3 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -29,6 +29,7 @@ data MoveOptions = MoveOptions
{ moveFiles :: CmdParams
, fromToOptions :: Either ToHere FromToOptions
, keyOptions :: Maybe KeyOptions
+ , batchOption :: BatchMode
}
data ToHere = ToHere
@@ -38,6 +39,7 @@ optParser desc = MoveOptions
<$> cmdParams desc
<*> (parsefrom <|> parseto)
<*> optional (parseKeyOptions <|> parseFailedTransfersOption)
+ <*> parseBatchOption
where
parsefrom = Right . FromRemote . parseRemoteOption <$> parseFromOption
parseto = herespecialcase <$> parseToOption
@@ -51,13 +53,17 @@ instance DeferredParseClass MoveOptions where
<$> pure (moveFiles v)
<*> either (pure . Left) (Right <$$> finishParse) (fromToOptions v)
<*> pure (keyOptions v)
+ <*> pure (batchOption v)
seek :: MoveOptions -> CommandSeek
-seek o = allowConcurrentOutput $
- withKeyOptions (keyOptions o) False
- (startKey o True)
- (withFilesInGit $ whenAnnexed $ start o True)
- (moveFiles o)
+seek o = allowConcurrentOutput $ do
+ let go = whenAnnexed $ start o True
+ case batchOption o of
+ Batch -> batchInput Right (batchCommandAction . go)
+ NoBatch -> withKeyOptions (keyOptions o) False
+ (startKey o True)
+ (withFilesInGit go)
+ (moveFiles o)
start :: MoveOptions -> Bool -> FilePath -> Key -> CommandStart
start o move f k = start' o move afile k (mkActionItem afile)