aboutsummaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs22
1 files changed, 15 insertions, 7 deletions
diff --git a/Annex.hs b/Annex.hs
index ef95ff174..a9cc68012 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -10,7 +10,6 @@
module Annex (
Annex,
AnnexState(..),
- OutputType(..),
new,
newState,
run,
@@ -19,6 +18,7 @@ module Annex (
changeState,
setFlag,
setField,
+ setOutput,
getFlag,
getField,
addCleanup,
@@ -37,12 +37,14 @@ import qualified Git
import qualified Git.Config
import Git.CatFile
import Git.CheckAttr
+import Git.SharedRepository
import qualified Git.Queue
import Types.Backend
import qualified Types.Remote
import Types.Crypto
import Types.BranchState
import Types.TrustLevel
+import Types.Messages
import Utility.State
import qualified Utility.Matcher
import qualified Data.Map as M
@@ -68,8 +70,6 @@ instance MonadBaseControl IO Annex where
where
unStAnnex (StAnnex st) = st
-data OutputType = NormalOutput | QuietOutput | JSONOutput
-
type Matcher a = Either [Utility.Matcher.Token a] (Utility.Matcher.Matcher a)
-- internal state storage
@@ -77,7 +77,7 @@ data AnnexState = AnnexState
{ repo :: Git.Repo
, backends :: [BackendA Annex]
, remotes :: [Types.Remote.RemoteA Annex]
- , output :: OutputType
+ , output :: MessageState
, force :: Bool
, fast :: Bool
, auto :: Bool
@@ -88,9 +88,10 @@ data AnnexState = AnnexState
, forcebackend :: Maybe String
, forcenumcopies :: Maybe Int
, limit :: Matcher (FilePath -> Annex Bool)
+ , shared :: Maybe SharedRepository
, forcetrust :: TrustMap
, trustmap :: Maybe TrustMap
- , ciphers :: M.Map EncryptedCipher Cipher
+ , ciphers :: M.Map StorableCipher Cipher
, lockpool :: M.Map FilePath Fd
, flags :: M.Map String Bool
, fields :: M.Map String String
@@ -102,7 +103,7 @@ newState gitrepo = AnnexState
{ repo = gitrepo
, backends = []
, remotes = []
- , output = NormalOutput
+ , output = defaultMessageState
, force = False
, fast = False
, auto = False
@@ -113,6 +114,7 @@ newState gitrepo = AnnexState
, forcebackend = Nothing
, forcenumcopies = Nothing
, limit = Left []
+ , shared = Nothing
, forcetrust = M.empty
, trustmap = Nothing
, ciphers = M.empty
@@ -122,7 +124,8 @@ newState gitrepo = AnnexState
, cleanup = M.empty
}
-{- Create and returns an Annex state object for the specified git repo. -}
+{- Makes an Annex state object for the specified git repo.
+ - Ensures the config is read, if it was not already. -}
new :: Git.Repo -> IO AnnexState
new gitrepo = newState <$> Git.Config.read gitrepo
@@ -147,6 +150,11 @@ addCleanup :: String -> Annex () -> Annex ()
addCleanup uid a = changeState $ \s ->
s { cleanup = M.insertWith' const uid a $ cleanup s }
+{- Sets the type of output to emit. -}
+setOutput :: OutputType -> Annex ()
+setOutput o = changeState $ \s ->
+ s { output = (output s) { outputType = o } }
+
{- Checks if a flag was set. -}
getFlag :: String -> Annex Bool
getFlag flag = fromMaybe False . M.lookup flag <$> getState flags