aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Command/Info.hs18
-rw-r--r--debian/changelog1
-rw-r--r--doc/git-annex-info.mdwn5
-rw-r--r--doc/todo/--batch_for_info.mdwn2
4 files changed, 23 insertions, 3 deletions
diff --git a/Command/Info.hs b/Command/Info.hs
index 8816ecbcf..426a1300b 100644
--- a/Command/Info.hs
+++ b/Command/Info.hs
@@ -38,6 +38,7 @@ import qualified Limit
import Messages.JSON (DualDisp(..))
import Annex.BloomFilter
import qualified Command.Unused
+import CmdLine.Batch
-- a named computation that produces a statistic
type Stat = StatState (Maybe (String, StatState String))
@@ -86,6 +87,7 @@ cmd = noCommit $ withGlobalOptions (jsonOption : annexedMatchingOptions) $
data InfoOptions = InfoOptions
{ infoFor :: CmdParams
, bytesOption :: Bool
+ , batchOption :: BatchMode
}
optParser :: CmdParamsDesc -> Parser InfoOptions
@@ -95,9 +97,12 @@ optParser desc = InfoOptions
( long "bytes"
<> help "display file sizes in bytes"
)
+ <*> parseBatchOption
seek :: InfoOptions -> CommandSeek
-seek o = withWords (start o) (infoFor o)
+seek o = case batchOption o of
+ NoBatch -> withWords (start o) (infoFor o)
+ Batch -> batchInput Right (itemInfo o)
start :: InfoOptions -> [String] -> CommandStart
start o [] = do
@@ -125,11 +130,18 @@ itemInfo o p = ifM (isdir p)
v' <- Remote.nameToUUID' p
case v' of
Right u -> uuidInfo o u
- Left _ -> ifAnnexed p (fileInfo o p) noinfo
+ Left _ -> ifAnnexed p
+ (fileInfo o p)
+ (noInfo p)
)
where
isdir = liftIO . catchBoolIO . (isDirectory <$$> getFileStatus)
- noinfo = error $ p ++ " is not a directory or an annexed file or a remote or a uuid"
+
+noInfo :: String -> Annex ()
+noInfo s = do
+ showStart "info" s
+ showNote $ " not a directory or an annexed file or a remote or a uuid"
+ showEndFail
dirInfo :: InfoOptions -> FilePath -> Annex ()
dirInfo o dir = showCustom (unwords ["info", dir]) $ do
diff --git a/debian/changelog b/debian/changelog
index 5e5b93032..077e36e76 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +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: Support --batch mode.
-- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400
diff --git a/doc/git-annex-info.mdwn b/doc/git-annex-info.mdwn
index 31c422703..37929bb5d 100644
--- a/doc/git-annex-info.mdwn
+++ b/doc/git-annex-info.mdwn
@@ -30,6 +30,11 @@ for the repository as a whole.
Show file sizes in bytes, disabling the default nicer units.
+* `--batch`
+
+ Enable batch mode, in which a line containing an item is read from stdin,
+ the information about it is output to stdout, and repeat.
+
* file matching options
When a directory is specified, the [[git-annex-matching-options]](1)
diff --git a/doc/todo/--batch_for_info.mdwn b/doc/todo/--batch_for_info.mdwn
index 007bc6d49..8f7fba456 100644
--- a/doc/todo/--batch_for_info.mdwn
+++ b/doc/todo/--batch_for_info.mdwn
@@ -1,3 +1,5 @@
I guess as other commands which take separate files/keys as its argument(s), having --batch for info command would be of benefit
[[!meta author=yoh]]
+
+> [[done]] --[[Joey]]