whereis --batch
This commit is contained in:
parent
d44177c774
commit
9b9b5a30e1
6 changed files with 33 additions and 13 deletions
|
@ -65,3 +65,8 @@ batchInput parser a = do
|
||||||
batchCommandAction :: CommandStart -> Annex ()
|
batchCommandAction :: CommandStart -> Annex ()
|
||||||
batchCommandAction a = maybe (batchBadInput Batch) (const noop)
|
batchCommandAction a = maybe (batchBadInput Batch) (const noop)
|
||||||
=<< callCommandAction' a
|
=<< 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
|
||||||
|
|
|
@ -55,8 +55,7 @@ seek o = allowConcurrentOutput $ do
|
||||||
, startSmall file
|
, startSmall file
|
||||||
)
|
)
|
||||||
case batchOption o of
|
case batchOption o of
|
||||||
Batch -> batchInput Right $
|
Batch -> batchFiles gofile
|
||||||
batchCommandAction . gofile
|
|
||||||
NoBatch -> do
|
NoBatch -> do
|
||||||
let go a = a gofile (addThese o)
|
let go a = a gofile (addThese o)
|
||||||
go (withFilesNotInGit (not $ includeDotFiles o))
|
go (withFilesNotInGit (not $ includeDotFiles o))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex command
|
{- 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.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -14,6 +14,7 @@ import Logs.Trust
|
||||||
import Logs.Web
|
import Logs.Web
|
||||||
import Remote.Web (getWebUrls)
|
import Remote.Web (getWebUrls)
|
||||||
import Annex.UUID
|
import Annex.UUID
|
||||||
|
import CmdLine.Batch
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
|
@ -26,19 +27,25 @@ cmd = noCommit $ withGlobalOptions (jsonOption : annexedMatchingOptions) $
|
||||||
data WhereisOptions = WhereisOptions
|
data WhereisOptions = WhereisOptions
|
||||||
{ whereisFiles :: CmdParams
|
{ whereisFiles :: CmdParams
|
||||||
, keyOptions :: Maybe KeyOptions
|
, keyOptions :: Maybe KeyOptions
|
||||||
|
, batchOption :: BatchMode
|
||||||
}
|
}
|
||||||
|
|
||||||
optParser :: CmdParamsDesc -> Parser WhereisOptions
|
optParser :: CmdParamsDesc -> Parser WhereisOptions
|
||||||
optParser desc = WhereisOptions
|
optParser desc = WhereisOptions
|
||||||
<$> cmdParams desc
|
<$> cmdParams desc
|
||||||
<*> optional (parseKeyOptions False)
|
<*> optional (parseKeyOptions False)
|
||||||
|
<*> parseBatchOption
|
||||||
|
|
||||||
seek :: WhereisOptions -> CommandSeek
|
seek :: WhereisOptions -> CommandSeek
|
||||||
seek o = do
|
seek o = do
|
||||||
m <- remoteMap id
|
m <- remoteMap id
|
||||||
|
let go = whenAnnexed $ start m
|
||||||
|
case batchOption o of
|
||||||
|
Batch -> batchFiles go
|
||||||
|
NoBatch ->
|
||||||
withKeyOptions (keyOptions o) False
|
withKeyOptions (keyOptions o) False
|
||||||
(startKeys m)
|
(startKeys m)
|
||||||
(withFilesInGit $ whenAnnexed $ start m)
|
(withFilesInGit go)
|
||||||
(whereisFiles o)
|
(whereisFiles o)
|
||||||
|
|
||||||
start :: M.Map UUID Remote -> FilePath -> Key -> CommandStart
|
start :: M.Map UUID Remote -> FilePath -> Key -> CommandStart
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -2,7 +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, add: Support --batch mode.
|
* info, add, whereis: Support --batch mode.
|
||||||
* Force output to be line-buffered, even when it's not connected to the
|
* Force output to be line-buffered, even when it's not connected to the
|
||||||
terminal. This is particuarly important for commands with --batch
|
terminal. This is particuarly important for commands with --batch
|
||||||
output, which was not always being flushed at an appropriate time.
|
output, which was not always being flushed at an appropriate time.
|
||||||
|
|
|
@ -22,11 +22,6 @@ For example:
|
||||||
|
|
||||||
# OPTIONS
|
# 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
|
* file matching options
|
||||||
|
|
||||||
The [[git-annex-matching-options]](1)
|
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.
|
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
|
# SEE ALSO
|
||||||
|
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
subject. IMHO yet another useful command to be batched
|
subject. IMHO yet another useful command to be batched
|
||||||
|
|
||||||
|
> [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Reference in a new issue