rmurl: --batch
* rmurl: Multiple pairs of files and urls can be provided on the command line. * rmurl: Added --batch mode. This commit was sponsored by Trenton Cronholm on Patreon.
This commit is contained in:
parent
e0be5b354a
commit
93852dd7e8
3 changed files with 43 additions and 7 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue