info: Support --batch mode.
This commit is contained in:
parent
27fd47fe38
commit
aa35f5cdf7
4 changed files with 23 additions and 3 deletions
|
@ -38,6 +38,7 @@ import qualified Limit
|
||||||
import Messages.JSON (DualDisp(..))
|
import Messages.JSON (DualDisp(..))
|
||||||
import Annex.BloomFilter
|
import Annex.BloomFilter
|
||||||
import qualified Command.Unused
|
import qualified Command.Unused
|
||||||
|
import CmdLine.Batch
|
||||||
|
|
||||||
-- a named computation that produces a statistic
|
-- a named computation that produces a statistic
|
||||||
type Stat = StatState (Maybe (String, StatState String))
|
type Stat = StatState (Maybe (String, StatState String))
|
||||||
|
@ -86,6 +87,7 @@ cmd = noCommit $ withGlobalOptions (jsonOption : annexedMatchingOptions) $
|
||||||
data InfoOptions = InfoOptions
|
data InfoOptions = InfoOptions
|
||||||
{ infoFor :: CmdParams
|
{ infoFor :: CmdParams
|
||||||
, bytesOption :: Bool
|
, bytesOption :: Bool
|
||||||
|
, batchOption :: BatchMode
|
||||||
}
|
}
|
||||||
|
|
||||||
optParser :: CmdParamsDesc -> Parser InfoOptions
|
optParser :: CmdParamsDesc -> Parser InfoOptions
|
||||||
|
@ -95,9 +97,12 @@ optParser desc = InfoOptions
|
||||||
( long "bytes"
|
( long "bytes"
|
||||||
<> help "display file sizes in bytes"
|
<> help "display file sizes in bytes"
|
||||||
)
|
)
|
||||||
|
<*> parseBatchOption
|
||||||
|
|
||||||
seek :: InfoOptions -> CommandSeek
|
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 :: InfoOptions -> [String] -> CommandStart
|
||||||
start o [] = do
|
start o [] = do
|
||||||
|
@ -125,11 +130,18 @@ itemInfo o p = ifM (isdir p)
|
||||||
v' <- Remote.nameToUUID' p
|
v' <- Remote.nameToUUID' p
|
||||||
case v' of
|
case v' of
|
||||||
Right u -> uuidInfo o u
|
Right u -> uuidInfo o u
|
||||||
Left _ -> ifAnnexed p (fileInfo o p) noinfo
|
Left _ -> ifAnnexed p
|
||||||
|
(fileInfo o p)
|
||||||
|
(noInfo p)
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
isdir = liftIO . catchBoolIO . (isDirectory <$$> getFileStatus)
|
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 :: InfoOptions -> FilePath -> Annex ()
|
||||||
dirInfo o dir = showCustom (unwords ["info", dir]) $ do
|
dirInfo o dir = showCustom (unwords ["info", dir]) $ do
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -2,6 +2,7 @@ git-annex (6.20160115) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* whereis --json: Urls are now listed inside the remote that claims them,
|
* whereis --json: Urls are now listed inside the remote that claims them,
|
||||||
rather than all together at the end.
|
rather than all together at the end.
|
||||||
|
* info: Support --batch mode.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400
|
-- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,11 @@ for the repository as a whole.
|
||||||
|
|
||||||
Show file sizes in bytes, disabling the default nicer units.
|
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
|
* file matching options
|
||||||
|
|
||||||
When a directory is specified, the [[git-annex-matching-options]](1)
|
When a directory is specified, the [[git-annex-matching-options]](1)
|
||||||
|
|
|
@ -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
|
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]]
|
[[!meta author=yoh]]
|
||||||
|
|
||||||
|
> [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue