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.
|
does not support graphical display, while xdot does.
|
||||||
* Debian: xdot is a better interactive viewer than dot, so Suggest
|
* Debian: xdot is a better interactive viewer than dot, so Suggest
|
||||||
xdot, rather than graphviz.
|
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
|
-- Joey Hess <id@joeyh.name> Mon, 21 Nov 2016 11:27:50 -0400
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex command
|
{- 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.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -10,18 +10,39 @@ module Command.RmUrl where
|
||||||
import Command
|
import Command
|
||||||
import Logs.Web
|
import Logs.Web
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
|
import CmdLine.Batch
|
||||||
|
|
||||||
cmd :: Command
|
cmd :: Command
|
||||||
cmd = notBareRepo $
|
cmd = notBareRepo $
|
||||||
command "rmurl" SectionCommon
|
command "rmurl" SectionCommon
|
||||||
"record file is not available at url"
|
"record file is not available at url"
|
||||||
(paramPair paramFile paramUrl)
|
(paramRepeating (paramPair paramFile paramUrl))
|
||||||
(withParams seek)
|
(seek <$$> optParser)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
data RmUrlOptions = RmUrlOptions
|
||||||
seek = withPairs start
|
{ 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
|
start (file, url) = flip whenAnnexed file $ \_ key -> do
|
||||||
showStart "rmurl" file
|
showStart "rmurl" file
|
||||||
next $ next $ cleanup url key
|
next $ next $ cleanup url key
|
||||||
|
|
|
@ -4,12 +4,24 @@ git-annex rmurl - record file is not available at url
|
||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
|
|
||||||
git annex rmurl `file url`
|
git annex rmurl `[file url ..]`
|
||||||
|
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
|
|
||||||
Record that the file is no longer available at the url.
|
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
|
# SEE ALSO
|
||||||
|
|
||||||
[[git-annex]](1)
|
[[git-annex]](1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue