summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CmdLine/Batch.hs5
-rw-r--r--Command/Add.hs3
-rw-r--r--Command/Whereis.hs17
-rw-r--r--debian/changelog2
-rw-r--r--doc/git-annex-whereis.mdwn17
-rw-r--r--doc/todo/--batch_for_whereis.mdwn2
6 files changed, 33 insertions, 13 deletions
diff --git a/CmdLine/Batch.hs b/CmdLine/Batch.hs
index e7706881a..0cbd3781d 100644
--- a/CmdLine/Batch.hs
+++ b/CmdLine/Batch.hs
@@ -65,3 +65,8 @@ batchInput parser a = do
batchCommandAction :: CommandStart -> Annex ()
batchCommandAction a = maybe (batchBadInput Batch) (const noop)
=<< callCommandAction' a
+
+-- Reads lines of batch input and passes the filepaths to a CommandStart
+-- to handle them.
+batchFiles :: (FilePath -> CommandStart) -> Annex ()
+batchFiles a = batchInput Right $ batchCommandAction . a
diff --git a/Command/Add.hs b/Command/Add.hs
index f2fcd2fb1..e85cdd6c1 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -55,8 +55,7 @@ seek o = allowConcurrentOutput $ do
, startSmall file
)
case batchOption o of
- Batch -> batchInput Right $
- batchCommandAction . gofile
+ Batch -> batchFiles gofile
NoBatch -> do
let go a = a gofile (addThese o)
go (withFilesNotInGit (not $ includeDotFiles o))
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
index 9117cde9e..bf4cbfe97 100644
--- a/Command/Whereis.hs
+++ b/Command/Whereis.hs
@@ -1,6 +1,6 @@
{- git-annex command
-
- - Copyright 2010-2014 Joey Hess <id@joeyh.name>
+ - Copyright 2010-2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -14,6 +14,7 @@ import Logs.Trust
import Logs.Web
import Remote.Web (getWebUrls)
import Annex.UUID
+import CmdLine.Batch
import qualified Data.Map as M
@@ -26,20 +27,26 @@ cmd = noCommit $ withGlobalOptions (jsonOption : annexedMatchingOptions) $
data WhereisOptions = WhereisOptions
{ whereisFiles :: CmdParams
, keyOptions :: Maybe KeyOptions
+ , batchOption :: BatchMode
}
optParser :: CmdParamsDesc -> Parser WhereisOptions
optParser desc = WhereisOptions
<$> cmdParams desc
<*> optional (parseKeyOptions False)
+ <*> parseBatchOption
seek :: WhereisOptions -> CommandSeek
seek o = do
m <- remoteMap id
- withKeyOptions (keyOptions o) False
- (startKeys m)
- (withFilesInGit $ whenAnnexed $ start m)
- (whereisFiles o)
+ let go = whenAnnexed $ start m
+ case batchOption o of
+ Batch -> batchFiles go
+ NoBatch ->
+ withKeyOptions (keyOptions o) False
+ (startKeys m)
+ (withFilesInGit go)
+ (whereisFiles o)
start :: M.Map UUID Remote -> FilePath -> Key -> CommandStart
start remotemap file key = start' remotemap key (Just file)
diff --git a/debian/changelog b/debian/changelog
index 81c1f3e6f..53b4d14e7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ git-annex (6.20160115) UNRELEASED; urgency=medium
* whereis --json: Urls are now listed inside the remote that claims them,
rather than all together at the end.
- * info, add: Support --batch mode.
+ * info, add, whereis: Support --batch mode.
* Force output to be line-buffered, even when it's not connected to the
terminal. This is particuarly important for commands with --batch
output, which was not always being flushed at an appropriate time.
diff --git a/doc/git-annex-whereis.mdwn b/doc/git-annex-whereis.mdwn
index ed77ad7fa..4611468ba 100644
--- a/doc/git-annex-whereis.mdwn
+++ b/doc/git-annex-whereis.mdwn
@@ -22,11 +22,6 @@ For example:
# OPTIONS
-* `--json`
-
- Enable JSON output. This is intended to be parsed by programs that use
- git-annex. Each line of output is a JSON object.
-
* file matching options
The [[git-annex-matching-options]](1)
@@ -44,6 +39,18 @@ For example:
Show whereis information for files found by last run of git-annex unused.
+* `--json`
+
+ Enable JSON output. This is intended to be parsed by programs that use
+ git-annex. Each line of output is a JSON object.
+
+* `--batch`
+
+ Enables batch mode, in which a file is read in a line from stdin,
+ its information displayed, and repeat.
+
+ Note that if the file is not an annexed file, an empty line will be
+ output instead.
# SEE ALSO
diff --git a/doc/todo/--batch_for_whereis.mdwn b/doc/todo/--batch_for_whereis.mdwn
index 8a2cd22bd..11cd3e8f8 100644
--- a/doc/todo/--batch_for_whereis.mdwn
+++ b/doc/todo/--batch_for_whereis.mdwn
@@ -1 +1,3 @@
subject. IMHO yet another useful command to be batched
+
+> [[done]] --[[Joey]]