dropkey: Add --batch.
This commit is contained in:
parent
8a54643618
commit
78fa865721
3 changed files with 37 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex command
|
{- git-annex command
|
||||||
-
|
-
|
||||||
- Copyright 2010 Joey Hess <id@joeyh.name>
|
- Copyright 2010,2016 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -17,22 +17,41 @@ cmd = noCommit $
|
||||||
command "dropkey" SectionPlumbing
|
command "dropkey" SectionPlumbing
|
||||||
"drops annexed content for specified keys"
|
"drops annexed content for specified keys"
|
||||||
(paramRepeating paramKey)
|
(paramRepeating paramKey)
|
||||||
(withParams seek)
|
(seek <$$> optParser)
|
||||||
|
|
||||||
seek :: CmdParams -> CommandSeek
|
data DropKeyOptions = DropKeyOptions
|
||||||
seek = withKeys start
|
{ toDrop :: [String]
|
||||||
|
, batchOption :: BatchMode
|
||||||
|
}
|
||||||
|
|
||||||
start :: Key -> CommandStart
|
optParser :: CmdParamsDesc -> Parser DropKeyOptions
|
||||||
start key = stopUnless (inAnnex key) $ do
|
optParser desc = DropKeyOptions
|
||||||
|
<$> cmdParams desc
|
||||||
|
<*> parseBatchOption
|
||||||
|
|
||||||
|
seek :: DropKeyOptions -> CommandSeek
|
||||||
|
seek o = do
|
||||||
unlessM (Annex.getState Annex.force) $
|
unlessM (Annex.getState Annex.force) $
|
||||||
error "dropkey can cause data loss; use --force if you're sure you want to do this"
|
error "dropkey can cause data loss; use --force if you're sure you want to do this"
|
||||||
|
withKeys start (toDrop o)
|
||||||
|
case batchOption o of
|
||||||
|
Batch -> batchInput parsekey $ batchCommandAction . start
|
||||||
|
NoBatch -> noop
|
||||||
|
where
|
||||||
|
parsekey = maybe (Left "bad key") Right . file2key
|
||||||
|
|
||||||
|
start :: Key -> CommandStart
|
||||||
|
start key = do
|
||||||
showStart' "dropkey" key Nothing
|
showStart' "dropkey" key Nothing
|
||||||
next $ perform key
|
next $ perform key
|
||||||
|
|
||||||
perform :: Key -> CommandPerform
|
perform :: Key -> CommandPerform
|
||||||
perform key = lockContentForRemoval key $ \contentlock -> do
|
perform key = ifM (inAnnex key)
|
||||||
|
( lockContentForRemoval key $ \contentlock -> do
|
||||||
removeAnnex contentlock
|
removeAnnex contentlock
|
||||||
next $ cleanup key
|
next $ cleanup key
|
||||||
|
, next $ return True
|
||||||
|
)
|
||||||
|
|
||||||
cleanup :: Key -> CommandCleanup
|
cleanup :: Key -> CommandCleanup
|
||||||
cleanup key = do
|
cleanup key = do
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -8,6 +8,7 @@ git-annex (6.20160230) UNRELEASED; urgency=medium
|
||||||
Thanks, Klaus Ethgen.
|
Thanks, Klaus Ethgen.
|
||||||
* Added dependencies on haskell mountpoints and disk-free-space
|
* Added dependencies on haskell mountpoints and disk-free-space
|
||||||
libraries, removing FFI code from git-annex.
|
libraries, removing FFI code from git-annex.
|
||||||
|
* dropkey: Add --batch.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Mon, 29 Feb 2016 13:00:30 -0400
|
-- Joey Hess <id@joeyh.name> Mon, 29 Feb 2016 13:00:30 -0400
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,13 @@ to have a file in the git repository pointing at them.
|
||||||
Warning: This command does not check that enough other copies of the content
|
Warning: This command does not check that enough other copies of the content
|
||||||
exist; using it can easily result in data loss.
|
exist; using it can easily result in data loss.
|
||||||
|
|
||||||
|
# OPTIONS
|
||||||
|
|
||||||
|
* `--batch`
|
||||||
|
|
||||||
|
Enables batch mode, in which lines containing keys to drop are read from
|
||||||
|
stdin.
|
||||||
|
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
||||||
[[git-annex]](1)
|
[[git-annex]](1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue