get: Add --batch and --json options.
This commit is contained in:
parent
92a401ae1e
commit
ed8ecbea0c
4 changed files with 38 additions and 10 deletions
|
@ -3,6 +3,7 @@ git-annex (6.20160614) UNRELEASED; urgency=medium
|
|||
* Webapp: Don't allow deleting a remote that has syncing disabled,
|
||||
as such a deletion will never finish.
|
||||
Thanks, Farhan Kathawala.
|
||||
* get: Add --batch and --json options.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Mon, 13 Jun 2016 21:52:24 -0400
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import Annex.Wanted
|
|||
import qualified Command.Move
|
||||
|
||||
cmd :: Command
|
||||
cmd = withGlobalOptions (jobsOption : annexedMatchingOptions) $
|
||||
cmd = withGlobalOptions (jobsOption : jsonOption : annexedMatchingOptions) $
|
||||
command "get" SectionCommon
|
||||
"make content of annexed files available"
|
||||
paramPaths (seek <$$> optParser)
|
||||
|
@ -26,6 +26,7 @@ data GetOptions = GetOptions
|
|||
, getFrom :: Maybe (DeferredParse Remote)
|
||||
, autoMode :: Bool
|
||||
, keyOptions :: Maybe KeyOptions
|
||||
, batchOption :: BatchMode
|
||||
}
|
||||
|
||||
optParser :: CmdParamsDesc -> Parser GetOptions
|
||||
|
@ -34,14 +35,18 @@ optParser desc = GetOptions
|
|||
<*> optional parseFromOption
|
||||
<*> parseAutoOption
|
||||
<*> optional (parseKeyOptions True)
|
||||
<*> parseBatchOption
|
||||
|
||||
seek :: GetOptions -> CommandSeek
|
||||
seek o = allowConcurrentOutput $ do
|
||||
from <- maybe (pure Nothing) (Just <$$> getParsed) (getFrom o)
|
||||
withKeyOptions (keyOptions o) (autoMode o)
|
||||
(startKeys from)
|
||||
(withFilesInGit $ whenAnnexed $ start o from)
|
||||
(getFiles o)
|
||||
let go = whenAnnexed $ start o from
|
||||
case batchOption o of
|
||||
Batch -> batchInput Right (batchCommandAction . go)
|
||||
NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
|
||||
(startKeys from)
|
||||
(withFilesInGit go)
|
||||
(getFiles o)
|
||||
|
||||
start :: GetOptions -> Maybe Remote -> FilePath -> Key -> CommandStart
|
||||
start o from file key = start' expensivecheck from key (Just file)
|
||||
|
|
|
@ -45,6 +45,11 @@ or transferring them from some kind of key-value store.
|
|||
as git-annex does not know the associated file, and the associated file
|
||||
may not even be in the current git working directory.
|
||||
|
||||
* file matching options
|
||||
|
||||
The [[git-annex-matching-options]](1)
|
||||
can be used to specify files to get.
|
||||
|
||||
* `--all`
|
||||
|
||||
Rather than specifying a filename or path to get, this option can be
|
||||
|
@ -60,10 +65,23 @@ or transferring them from some kind of key-value store.
|
|||
|
||||
Use this option to get a specified key.
|
||||
|
||||
* file matching options
|
||||
|
||||
The [[git-annex-matching-options]](1)
|
||||
can be used to specify files to get.
|
||||
* `--batch`
|
||||
|
||||
Enables batch mode, in which lines containing names of files to get
|
||||
are read from stdin.
|
||||
|
||||
As each specified file is processed, the usual progress output is
|
||||
displayed. If the specified file's content is already present, or
|
||||
it is not an annexed file, a blank line is output in response instead.
|
||||
|
||||
Since the usual progress output while getting a file is verbose and not
|
||||
machine-parseable, you may want to use --json in combination with
|
||||
--batch.
|
||||
|
||||
* `--json`
|
||||
|
||||
Enable JSON output. This is intended to be parsed by programs that use
|
||||
git-annex. Each line of output is a JSON object.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
It seems that it would be tremendously useful, see e.g. our [datalad install](https://github.com/datalad/datalad/issues/553)
|
||||
|
||||
[[!meta author =yoh]]
|
||||
[[!meta author=yoh]]
|
||||
|
||||
> [[done]] although the output while getting a file is not
|
||||
> machine-parseable. So, I made --json also work for get, but enabling
|
||||
> json output disables any progress display. --[[Joey]]
|
||||
|
|
Loading…
Reference in a new issue