diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-05-06 13:44:53 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-05-06 13:44:53 -0400 |
commit | 2bbb276e38fb8503daccf7a419336d67c0a23c9c (patch) | |
tree | d796474a8b82bc5e79ae99a40ee93fd81cdf83a7 /Command | |
parent | 582fa3e2f10f1e1064314a8a1d9bb5aa5cf84f92 (diff) |
contentlocation, examinekey, lookupkey: Added --batch mode option.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/ContentLocation.hs | 11 | ||||
-rw-r--r-- | Command/ExamineKey.hs | 9 | ||||
-rw-r--r-- | Command/LookupKey.hs | 12 |
3 files changed, 18 insertions, 14 deletions
diff --git a/Command/ContentLocation.hs b/Command/ContentLocation.hs index 3f4775f57..10879f5b1 100644 --- a/Command/ContentLocation.hs +++ b/Command/ContentLocation.hs @@ -9,19 +9,20 @@ module Command.ContentLocation where import Common.Annex import Command +import CmdLine.Batch import Annex.Content cmd :: [Command] -cmd = [noCommit $ noMessages $ +cmd = [withOptions [batchOption] $ noCommit $ noMessages $ command "contentlocation" (paramRepeating paramKey) seek SectionPlumbing "looks up content for a key"] seek :: CommandSeek -seek = withKeys start +seek = batchable withKeys start -start :: Key -> CommandStart -start k = do - liftIO . maybe exitFailure putStrLn +start :: Batchable Key +start batchmode k = do + maybe (batchBadInput batchmode) (liftIO . putStrLn) =<< inAnnex' (pure True) Nothing check k stop where diff --git a/Command/ExamineKey.hs b/Command/ExamineKey.hs index 00d4d3a95..05db9817a 100644 --- a/Command/ExamineKey.hs +++ b/Command/ExamineKey.hs @@ -9,21 +9,22 @@ module Command.ExamineKey where import Common.Annex import Command +import CmdLine.Batch import qualified Utility.Format import Command.Find (formatOption, getFormat, showFormatted, keyVars) import Types.Key cmd :: [Command] -cmd = [noCommit $ noMessages $ withOptions [formatOption, jsonOption] $ +cmd = [noCommit $ noMessages $ withOptions [formatOption, jsonOption, batchOption] $ command "examinekey" (paramRepeating paramKey) seek SectionPlumbing "prints information from a key"] seek :: CommandSeek seek ps = do format <- getFormat - withKeys (start format) ps + batchable withKeys (start format) ps -start :: Maybe Utility.Format.Format -> Key -> CommandStart -start format key = do +start :: Maybe Utility.Format.Format -> Batchable Key +start format _ key = do showFormatted format (key2file key) (keyVars key) stop diff --git a/Command/LookupKey.hs b/Command/LookupKey.hs index 0485232ae..6e7f07049 100644 --- a/Command/LookupKey.hs +++ b/Command/LookupKey.hs @@ -9,18 +9,20 @@ module Command.LookupKey where import Common.Annex import Command +import CmdLine.Batch import Annex.CatFile import Types.Key cmd :: [Command] -cmd = [notBareRepo $ noCommit $ noMessages $ +cmd = [withOptions [batchOption] $ notBareRepo $ noCommit $ noMessages $ command "lookupkey" (paramRepeating paramFile) seek SectionPlumbing "looks up key used for file"] seek :: CommandSeek -seek = withStrings start +seek = batchable withStrings start -start :: String -> CommandStart -start file = do - liftIO . maybe exitFailure (putStrLn . key2file) =<< catKeyFile file +start :: Batchable String +start batchmode file = do + maybe (batchBadInput batchmode) (liftIO . putStrLn . key2file) + =<< catKeyFile file stop |