drop: Add --batch and --json options.

This commit is contained in:
Joey Hess 2016-07-06 11:54:46 -04:00
parent a0d6ec1c8a
commit 5171e98988
Failed to extract signature
5 changed files with 28 additions and 6 deletions

View file

@ -3,7 +3,7 @@ git-annex (6.20160614) UNRELEASED; urgency=medium
* Webapp: Don't allow deleting a remote that has syncing disabled, * Webapp: Don't allow deleting a remote that has syncing disabled,
as such a deletion will never finish. as such a deletion will never finish.
Thanks, Farhan Kathawala. Thanks, Farhan Kathawala.
* get: Add --batch and --json options. * get, drop: Add --batch and --json options.
* New url for git-remote-gcrypt, now maintained by spwhitton. * New url for git-remote-gcrypt, now maintained by spwhitton.
* testremote: Fix crash when testing a freshly made external special remote. * testremote: Fix crash when testing a freshly made external special remote.

View file

@ -23,7 +23,7 @@ import System.Log.Logger (debugM)
import qualified Data.Set as S import qualified Data.Set as S
cmd :: Command cmd :: Command
cmd = withGlobalOptions (jobsOption : annexedMatchingOptions) $ cmd = withGlobalOptions (jobsOption : jsonOption : annexedMatchingOptions) $
command "drop" SectionCommon command "drop" SectionCommon
"remove content of files from repository" "remove content of files from repository"
paramPaths (seek <$$> optParser) paramPaths (seek <$$> optParser)
@ -33,6 +33,7 @@ data DropOptions = DropOptions
, dropFrom :: Maybe (DeferredParse Remote) , dropFrom :: Maybe (DeferredParse Remote)
, autoMode :: Bool , autoMode :: Bool
, keyOptions :: Maybe KeyOptions , keyOptions :: Maybe KeyOptions
, batchOption :: BatchMode
} }
optParser :: CmdParamsDesc -> Parser DropOptions optParser :: CmdParamsDesc -> Parser DropOptions
@ -41,6 +42,7 @@ optParser desc = DropOptions
<*> optional parseDropFromOption <*> optional parseDropFromOption
<*> parseAutoOption <*> parseAutoOption
<*> optional (parseKeyOptions False) <*> optional (parseKeyOptions False)
<*> parseBatchOption
parseDropFromOption :: Parser (DeferredParse Remote) parseDropFromOption :: Parser (DeferredParse Remote)
parseDropFromOption = parseRemoteOption $ strOption parseDropFromOption = parseRemoteOption $ strOption
@ -51,10 +53,14 @@ parseDropFromOption = parseRemoteOption $ strOption
seek :: DropOptions -> CommandSeek seek :: DropOptions -> CommandSeek
seek o = allowConcurrentOutput $ seek o = allowConcurrentOutput $
withKeyOptions (keyOptions o) (autoMode o) case batchOption o of
Batch -> batchInput Right (batchCommandAction . go)
NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
(startKeys o) (startKeys o)
(withFilesInGit $ whenAnnexed $ start o) (withFilesInGit go)
(dropFiles o) (dropFiles o)
where
go = whenAnnexed $ start o
start :: DropOptions -> FilePath -> Key -> CommandStart start :: DropOptions -> FilePath -> Key -> CommandStart
start o file key = start' o key (Just file) start o file key = start' o key (Just file)

View file

@ -61,6 +61,16 @@ safe to do so.
when git-annex has to contact remotes to check if it can drop files. when git-annex has to contact remotes to check if it can drop files.
For example: `-J4` For example: `-J4`
* `--batch`
Enables batch mode, in which lines containing names of files to drop
are read from stdin.
* `--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 # SEE ALSO
[[git-annex]](1) [[git-annex]](1)

View file

@ -1,3 +1,6 @@
in the spirit of [[todo/--batch_for_add/]], [[todo/--batch_for_info/]], [[todo/--batch_for_find/]] and [[todo/--batch_for_whereis/]], why not add `--batch` to get/drop/import operations? in the spirit of [[todo/--batch_for_add/]], [[todo/--batch_for_info/]], [[todo/--batch_for_find/]] and [[todo/--batch_for_whereis/]], why not add `--batch` to get/drop/import operations?
I am writing a script to get a bunch of arbitrary files and i want to avoid the overhead of running git-annex multiple times. I know i can use `annex.alwayscommit=false` but that is rather counter-intuitive as well. --[[anarcat]] I am writing a script to get a bunch of arbitrary files and i want to avoid the overhead of running git-annex multiple times. I know i can use `annex.alwayscommit=false` but that is rather counter-intuitive as well. --[[anarcat]]
> [[done]] for add and drop. (Not for import, but if someone requests it
> with a use case we'll see.) --[[Joey]]

View file

@ -1,3 +1,6 @@
There is a dropkey --batch, so I guess I could workaround but probably would be nice for consistency to have --batch mode for drop itself as well There is a dropkey --batch, so I guess I could workaround but probably would be nice for consistency to have --batch mode for drop itself as well
[[!meta author=yoh]] [[!meta author=yoh]]
> [[done]]; went ahead and added drop --batch to be symmetric with get
> --batch. --[[Joey]]