summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-07-06 11:54:46 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-07-06 11:56:11 -0400
commit4017cd1928435bef10dcb5183ddcc08945ba8bef (patch)
treeccb0b0b675bd915e44d3be836734ef3039c148c0
parentc87785692855f40d1507da6eb2c52ade63365479 (diff)
drop: Add --batch and --json options.
-rw-r--r--CHANGELOG2
-rw-r--r--Command/Drop.hs16
-rw-r--r--doc/git-annex-drop.mdwn10
-rw-r--r--doc/todo/batch_get__47__drop__47__etc.mdwn3
-rw-r--r--doc/todo/drop_--batch.mdwn3
5 files changed, 28 insertions, 6 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 23a50c76d..3836b1794 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,7 +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.
+ * get, drop: Add --batch and --json options.
* New url for git-remote-gcrypt, now maintained by spwhitton.
* testremote: Fix crash when testing a freshly made external special remote.
diff --git a/Command/Drop.hs b/Command/Drop.hs
index 3513caba9..16196f0ca 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -23,7 +23,7 @@ import System.Log.Logger (debugM)
import qualified Data.Set as S
cmd :: Command
-cmd = withGlobalOptions (jobsOption : annexedMatchingOptions) $
+cmd = withGlobalOptions (jobsOption : jsonOption : annexedMatchingOptions) $
command "drop" SectionCommon
"remove content of files from repository"
paramPaths (seek <$$> optParser)
@@ -33,6 +33,7 @@ data DropOptions = DropOptions
, dropFrom :: Maybe (DeferredParse Remote)
, autoMode :: Bool
, keyOptions :: Maybe KeyOptions
+ , batchOption :: BatchMode
}
optParser :: CmdParamsDesc -> Parser DropOptions
@@ -41,6 +42,7 @@ optParser desc = DropOptions
<*> optional parseDropFromOption
<*> parseAutoOption
<*> optional (parseKeyOptions False)
+ <*> parseBatchOption
parseDropFromOption :: Parser (DeferredParse Remote)
parseDropFromOption = parseRemoteOption $ strOption
@@ -51,10 +53,14 @@ parseDropFromOption = parseRemoteOption $ strOption
seek :: DropOptions -> CommandSeek
seek o = allowConcurrentOutput $
- withKeyOptions (keyOptions o) (autoMode o)
- (startKeys o)
- (withFilesInGit $ whenAnnexed $ start o)
- (dropFiles o)
+ case batchOption o of
+ Batch -> batchInput Right (batchCommandAction . go)
+ NoBatch -> withKeyOptions (keyOptions o) (autoMode o)
+ (startKeys o)
+ (withFilesInGit go)
+ (dropFiles o)
+ where
+ go = whenAnnexed $ start o
start :: DropOptions -> FilePath -> Key -> CommandStart
start o file key = start' o key (Just file)
diff --git a/doc/git-annex-drop.mdwn b/doc/git-annex-drop.mdwn
index 2e207cd8b..0bbbd78df 100644
--- a/doc/git-annex-drop.mdwn
+++ b/doc/git-annex-drop.mdwn
@@ -61,6 +61,16 @@ safe to do so.
when git-annex has to contact remotes to check if it can drop files.
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
[[git-annex]](1)
diff --git a/doc/todo/batch_get__47__drop__47__etc.mdwn b/doc/todo/batch_get__47__drop__47__etc.mdwn
index 25da67c96..154d4aca6 100644
--- a/doc/todo/batch_get__47__drop__47__etc.mdwn
+++ b/doc/todo/batch_get__47__drop__47__etc.mdwn
@@ -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?
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]]
diff --git a/doc/todo/drop_--batch.mdwn b/doc/todo/drop_--batch.mdwn
index 68c7a5a64..775798752 100644
--- a/doc/todo/drop_--batch.mdwn
+++ b/doc/todo/drop_--batch.mdwn
@@ -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
[[!meta author=yoh]]
+
+> [[done]]; went ahead and added drop --batch to be symmetric with get
+> --batch. --[[Joey]]