git-annex/Annex/Quvi.hs
Joey Hess eb33569f9d remove Params constructor from Utility.SafeCommand
This removes a bit of complexity, and should make things faster
(avoids tokenizing Params string), and probably involve less garbage
collection.

In a few places, it was useful to use Params to avoid needing a list,
but that is easily avoided.

Problems noticed while doing this conversion:

	* Some uses of Params "oneword" which was entirely unnecessary
	  overhead.
	* A few places that built up a list of parameters with ++
	  and then used Params to split it!

Test suite passes.
2015-06-01 13:52:23 -04:00

33 lines
854 B
Haskell

{- quvi options for git-annex
-
- Copyright 2013 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE Rank2Types #-}
module Annex.Quvi where
import Common.Annex
import qualified Annex
import Utility.Quvi
import Utility.Url
withQuviOptions :: forall a. Query a -> [QuviParams] -> URLString -> Annex a
withQuviOptions a ps url = do
v <- quviVersion
opts <- map Param . annexQuviOptions <$> Annex.getGitConfig
liftIO $ a v (concatMap (\mkp -> mkp v) ps ++ opts) url
quviSupported :: URLString -> Annex Bool
quviSupported u = liftIO . flip supported u =<< quviVersion
quviVersion :: Annex QuviVersion
quviVersion = go =<< Annex.getState Annex.quviversion
where
go (Just v) = return v
go Nothing = do
v <- liftIO probeVersion
Annex.changeState $ \s -> s { Annex.quviversion = Just v }
return v