diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | Command/Copy.hs | 14 | ||||
-rw-r--r-- | Command/Move.hs | 16 | ||||
-rw-r--r-- | doc/git-annex-copy.mdwn | 13 | ||||
-rw-r--r-- | doc/git-annex-move.mdwn | 13 | ||||
-rw-r--r-- | doc/todo/--batch_for_copy.mdwn | 2 |
6 files changed, 49 insertions, 10 deletions
@@ -10,6 +10,7 @@ git-annex (6.20170521) UNRELEASED; urgency=medium * test: Avoid most situations involving failure to delete test directories, by forking a worker process and only deleting the test directory once it exits. + * move, copy: Support --batch. -- Joey Hess <id@joeyh.name> Sat, 17 Jun 2017 13:02:24 -0400 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) diff --git a/doc/git-annex-copy.mdwn b/doc/git-annex-copy.mdwn index ecf78e905..c15a29f72 100644 --- a/doc/git-annex-copy.mdwn +++ b/doc/git-annex-copy.mdwn @@ -75,6 +75,19 @@ Copies the content of files from or to another remote. The [[git-annex-matching-options]](1) can be used to specify files to copy. +* `--batch` + + Enables batch mode, in which lines containing names of files to copy + are read from stdin. + + As each specified file is processed, the usual progress output is + displayed. If a file's content does not need to be copied or it + is not an annexed file, a blank line is output in response instead. + + Since the usual output while copying a file is verbose and not + machine-parseable, you may want to use --json in combination with + --batch. + * `--json` Enable JSON output. This is intended to be parsed by programs that use diff --git a/doc/git-annex-move.mdwn b/doc/git-annex-move.mdwn index 0aa349dee..4e42e934f 100644 --- a/doc/git-annex-move.mdwn +++ b/doc/git-annex-move.mdwn @@ -70,6 +70,19 @@ Moves the content of files from or to another remote. The [[git-annex-matching-options]](1) can be used to specify files to move. +* `--batch` + + Enables batch mode, in which lines containing names of files to move + are read from stdin. + + As each specified file is processed, the usual progress output is + displayed. If a file's content does not need to be moved or it + is not an annexed file, a blank line is output in response instead. + + Since the usual output while moving a file is verbose and not + machine-parseable, you may want to use --json in combination with + --batch. + * `--json` Enable JSON output. This is intended to be parsed by programs that use diff --git a/doc/todo/--batch_for_copy.mdwn b/doc/todo/--batch_for_copy.mdwn index 53cb77eec..0db965677 100644 --- a/doc/todo/--batch_for_copy.mdwn +++ b/doc/todo/--batch_for_copy.mdwn @@ -7,3 +7,5 @@ nothing """]] [!meta author=yoh] + +> [[done]] for copy and move --[[Joey]] |