diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-01-15 15:56:47 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-01-15 15:56:47 -0400 |
commit | 74f0a01c083b903497476995809a2a65b9911cc4 (patch) | |
tree | fe34ae7e145d015532bb0be683a8e1963fc018a6 /Command | |
parent | 6979ebdbd1f501344431e2d556e196dc5f5652bf (diff) |
info: Support --batch mode.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Info.hs | 18 |
1 files changed, 15 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 |