summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-09-01 13:35:07 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-09-01 13:35:07 -0400
commit57dd34c6be5dbc01286108fd943ff9e02956e8aa (patch)
tree7071f2ded704a447fb2918ff3e0ca4d84bac03cc
parent55783d886d3300555d4b68ff7323e2365928e059 (diff)
generalize quiet flag to output type
This will allow adding other styles of output.
-rw-r--r--Annex.hs7
-rw-r--r--Command/Init.hs2
-rw-r--r--Content.hs3
-rw-r--r--Messages.hs7
-rw-r--r--Options.hs6
5 files changed, 13 insertions, 12 deletions
diff --git a/Annex.hs b/Annex.hs
index 287aed875..fac5d27e4 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -10,6 +10,7 @@
module Annex (
Annex,
AnnexState(..),
+ OutputType(..),
new,
run,
eval,
@@ -48,7 +49,7 @@ data AnnexState = AnnexState
, backends :: [Backend Annex]
, remotes :: [Remote Annex]
, repoqueue :: Queue
- , quiet :: Bool
+ , output :: OutputType
, force :: Bool
, fast :: Bool
, branchstate :: BranchState
@@ -63,13 +64,15 @@ data AnnexState = AnnexState
, cipher :: Maybe Cipher
}
+data OutputType = NormalOutput | QuietOutput
+
newState :: Git.Repo -> AnnexState
newState gitrepo = AnnexState
{ repo = gitrepo
, backends = []
, remotes = []
, repoqueue = empty
- , quiet = False
+ , output = NormalOutput
, force = False
, fast = False
, branchstate = startBranchState
diff --git a/Command/Init.hs b/Command/Init.hs
index 2abe4c661..6ba7df682 100644
--- a/Command/Init.hs
+++ b/Command/Init.hs
@@ -7,8 +7,6 @@
module Command.Init where
-import Control.Monad
-
import Command
import qualified Annex
import UUID
diff --git a/Content.hs b/Content.hs
index 1c2475240..e4bbee528 100644
--- a/Content.hs
+++ b/Content.hs
@@ -23,11 +23,10 @@ module Content (
saveState
) where
-import System.IO.Error (try)
import System.Directory
import Control.Monad.State (liftIO)
import System.Path
-import Control.Monad (when, filterM)
+import Control.Monad
import System.Posix.Files
import System.FilePath
import Data.Maybe
diff --git a/Messages.hs b/Messages.hs
index 36f0b89c5..b2c871ede 100644
--- a/Messages.hs
+++ b/Messages.hs
@@ -9,7 +9,6 @@ module Messages where
import Control.Monad.State (liftIO)
import System.IO
-import Control.Monad (unless)
import Data.String.Utils
import Types
@@ -17,8 +16,10 @@ import qualified Annex
verbose :: Annex () -> Annex ()
verbose a = do
- q <- Annex.getState Annex.quiet
- unless q a
+ output <- Annex.getState Annex.output
+ case output of
+ Annex.NormalOutput -> a
+ _ -> return ()
showStart :: String -> String -> Annex ()
showStart command file = verbose $ liftIO $ do
diff --git a/Options.hs b/Options.hs
index 7f78f44f6..768a1c289 100644
--- a/Options.hs
+++ b/Options.hs
@@ -26,9 +26,9 @@ commonOptions =
"allow actions that may lose annexed data"
, Option ['F'] ["fast"] (NoArg (setfast True))
"avoid slow operations"
- , Option ['q'] ["quiet"] (NoArg (setquiet True))
+ , Option ['q'] ["quiet"] (NoArg (setoutput Annex.QuietOutput))
"avoid verbose output"
- , Option ['v'] ["verbose"] (NoArg (setquiet False))
+ , Option ['v'] ["verbose"] (NoArg (setoutput Annex.NormalOutput))
"allow verbose output (default)"
, Option ['d'] ["debug"] (NoArg (setdebug))
"show debug messages"
@@ -38,7 +38,7 @@ commonOptions =
where
setforce v = Annex.changeState $ \s -> s { Annex.force = v }
setfast v = Annex.changeState $ \s -> s { Annex.fast = v }
- setquiet v = Annex.changeState $ \s -> s { Annex.quiet = v }
+ setoutput v = Annex.changeState $ \s -> s { Annex.output = v }
setforcebackend v = Annex.changeState $ \s -> s { Annex.forcebackend = Just v }
setdebug = liftIO $ updateGlobalLogger rootLoggerName $
setLevel DEBUG