aboutsummaryrefslogtreecommitdiff
path: root/Command/Drop.hs
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 /Command/Drop.hs
parentc87785692855f40d1507da6eb2c52ade63365479 (diff)
drop: Add --batch and --json options.
Diffstat (limited to 'Command/Drop.hs')
-rw-r--r--Command/Drop.hs16
1 files changed, 11 insertions, 5 deletions
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)