data BatchMode = Batch | NoBatch
-batchOption :: Parser BatchMode
-batchOption = flag NoBatch Batch
+parseBatchOption :: Parser BatchMode
+parseBatchOption = flag NoBatch Batch
( long "batch"
<> help "enable batch mode"
)
-type Batchable t = BatchMode -> t -> CommandStart
-
--- A Batchable command can run in batch mode, or not.
+-- A batchable command can run in batch mode, or not.
-- In batch mode, one line at a time is read, parsed, and a reply output to
-- stdout. In non batch mode, the command's parameters are parsed and
-- a reply output for each.
where
batchparser = (,,)
<$> parser
- <*> batchOption
+ <*> parseBatchOption
<*> cmdParams paramdesc
batchseeker (opts, NoBatch, params) = mapM_ (go NoBatch opts) params
batchBadInput :: BatchMode -> Annex ()
batchBadInput NoBatch = liftIO exitFailure
batchBadInput Batch = liftIO $ putStrLn ""
+
+-- Reads lines of batch mode input and passes to the action to handle.
+batchSeek :: (String -> Annex ()) -> Annex ()
+batchSeek a = do
+ mp <- liftIO $ catchMaybeIO getLine
+ case mp of
+ Nothing -> return ()
+ Just p -> do
+ a p
+ batchSeek a
import Annex.FileMatcher
import Logs.Location
import Utility.Metered
+import CmdLine.Batch
import qualified Annex.Transfer as Transfer
#ifdef WITH_QUVI
import Annex.Quvi
, suffixOption :: Maybe String
, relaxedOption :: Bool
, rawOption :: Bool
+ , batchOption :: BatchMode
}
optParser :: CmdParamsDesc -> Parser AddUrlOptions
))
<*> parseRelaxedOption
<*> parseRawOption
+ <*> parseBatchOption
parseRelaxedOption :: Parser Bool
parseRelaxedOption = switch
)
seek :: AddUrlOptions -> CommandSeek
-seek o = allowConcurrentOutput $
- forM_ (addUrls o) $ \u -> do
+seek o = allowConcurrentOutput $ do
+ forM_ (addUrls o) go
+ case batchOption o of
+ Batch -> batchSeek go
+ NoBatch -> noop
+ where
+ go u = do
r <- Remote.claimingUrl u
if Remote.uuid r == webUUID || rawOption o
then void $ commandAction $ startWeb o u
that were present. Probably caused by a change to what git status
displays in this situation. Fixed by treating files git thinks are
modified the same as typechanged files.
+ * addurl: Added --batch option.
-- Joey Hess <id@joeyh.name> Sat, 19 Dec 2015 13:31:17 -0400