summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG3
-rw-r--r--Command/RmUrl.hs33
-rw-r--r--doc/git-annex-rmurl.mdwn14
3 files changed, 43 insertions, 7 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 76da79eaa..384dc3c3b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,9 @@ git-annex (6.20161119) UNRELEASED; urgency=medium
does not support graphical display, while xdot does.
* Debian: xdot is a better interactive viewer than dot, so Suggest
xdot, rather than graphviz.
+ * rmurl: Multiple pairs of files and urls can be provided on the
+ command line.
+ * rmurl: Added --batch mode.
-- Joey Hess <id@joeyh.name> Mon, 21 Nov 2016 11:27:50 -0400
diff --git a/Command/RmUrl.hs b/Command/RmUrl.hs
index eb78f7ba7..0f33d66b2 100644
--- a/Command/RmUrl.hs
+++ b/Command/RmUrl.hs
@@ -1,6 +1,6 @@
{- git-annex command
-
- - Copyright 2013 Joey Hess <id@joeyh.name>
+ - Copyright 2013-2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -10,18 +10,39 @@ module Command.RmUrl where
import Command
import Logs.Web
import qualified Remote
+import CmdLine.Batch
cmd :: Command
cmd = notBareRepo $
command "rmurl" SectionCommon
"record file is not available at url"
- (paramPair paramFile paramUrl)
- (withParams seek)
+ (paramRepeating (paramPair paramFile paramUrl))
+ (seek <$$> optParser)
-seek :: CmdParams -> CommandSeek
-seek = withPairs start
+data RmUrlOptions = RmUrlOptions
+ { rmThese :: CmdParams
+ , batchOption :: BatchMode
+ }
-start :: (FilePath, String) -> CommandStart
+optParser :: CmdParamsDesc -> Parser RmUrlOptions
+optParser desc = RmUrlOptions
+ <$> cmdParams desc
+ <*> parseBatchOption
+
+seek :: RmUrlOptions -> CommandSeek
+seek o = case batchOption o of
+ Batch -> batchInput batchParser (batchCommandAction . start)
+ NoBatch -> withPairs start (rmThese o)
+
+-- Split on the last space, since a FilePath can contain whitespace,
+-- but a url should not.
+batchParser :: String -> Either String (FilePath, URLString)
+batchParser s = case separate (== ' ') (reverse s) of
+ (ru, rf)
+ | null ru || null rf -> Left "Expected: \"file url\""
+ | otherwise -> Right (reverse rf, reverse ru)
+
+start :: (FilePath, URLString) -> CommandStart
start (file, url) = flip whenAnnexed file $ \_ key -> do
showStart "rmurl" file
next $ next $ cleanup url key
diff --git a/doc/git-annex-rmurl.mdwn b/doc/git-annex-rmurl.mdwn
index 5faf9ea39..e971e622e 100644
--- a/doc/git-annex-rmurl.mdwn
+++ b/doc/git-annex-rmurl.mdwn
@@ -4,12 +4,24 @@ git-annex rmurl - record file is not available at url
# SYNOPSIS
-git annex rmurl `file url`
+git annex rmurl `[file url ..]`
# DESCRIPTION
Record that the file is no longer available at the url.
+If nothing is specified on the command line, they are instead read
+from stdin. Any number of lines can be provided in this mode,
+each containing a file and and url, separated by a single space.
+
+# OPTIONS
+
+* `--batch`
+
+ Enables batch mode, in which lines are read from stdin.
+ Each line should contain the file, and the url to remove from that file,
+ separated by a single space.
+
# SEE ALSO
[[git-annex]](1)