generalize quiet flag to output type
This will allow adding other styles of output.
This commit is contained in:
parent
55783d886d
commit
57dd34c6be
5 changed files with 13 additions and 12 deletions
7
Annex.hs
7
Annex.hs
|
@ -10,6 +10,7 @@
|
||||||
module Annex (
|
module Annex (
|
||||||
Annex,
|
Annex,
|
||||||
AnnexState(..),
|
AnnexState(..),
|
||||||
|
OutputType(..),
|
||||||
new,
|
new,
|
||||||
run,
|
run,
|
||||||
eval,
|
eval,
|
||||||
|
@ -48,7 +49,7 @@ data AnnexState = AnnexState
|
||||||
, backends :: [Backend Annex]
|
, backends :: [Backend Annex]
|
||||||
, remotes :: [Remote Annex]
|
, remotes :: [Remote Annex]
|
||||||
, repoqueue :: Queue
|
, repoqueue :: Queue
|
||||||
, quiet :: Bool
|
, output :: OutputType
|
||||||
, force :: Bool
|
, force :: Bool
|
||||||
, fast :: Bool
|
, fast :: Bool
|
||||||
, branchstate :: BranchState
|
, branchstate :: BranchState
|
||||||
|
@ -63,13 +64,15 @@ data AnnexState = AnnexState
|
||||||
, cipher :: Maybe Cipher
|
, cipher :: Maybe Cipher
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data OutputType = NormalOutput | QuietOutput
|
||||||
|
|
||||||
newState :: Git.Repo -> AnnexState
|
newState :: Git.Repo -> AnnexState
|
||||||
newState gitrepo = AnnexState
|
newState gitrepo = AnnexState
|
||||||
{ repo = gitrepo
|
{ repo = gitrepo
|
||||||
, backends = []
|
, backends = []
|
||||||
, remotes = []
|
, remotes = []
|
||||||
, repoqueue = empty
|
, repoqueue = empty
|
||||||
, quiet = False
|
, output = NormalOutput
|
||||||
, force = False
|
, force = False
|
||||||
, fast = False
|
, fast = False
|
||||||
, branchstate = startBranchState
|
, branchstate = startBranchState
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
module Command.Init where
|
module Command.Init where
|
||||||
|
|
||||||
import Control.Monad
|
|
||||||
|
|
||||||
import Command
|
import Command
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import UUID
|
import UUID
|
||||||
|
|
|
@ -23,11 +23,10 @@ module Content (
|
||||||
saveState
|
saveState
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import System.IO.Error (try)
|
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import Control.Monad.State (liftIO)
|
import Control.Monad.State (liftIO)
|
||||||
import System.Path
|
import System.Path
|
||||||
import Control.Monad (when, filterM)
|
import Control.Monad
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
|
@ -9,7 +9,6 @@ module Messages where
|
||||||
|
|
||||||
import Control.Monad.State (liftIO)
|
import Control.Monad.State (liftIO)
|
||||||
import System.IO
|
import System.IO
|
||||||
import Control.Monad (unless)
|
|
||||||
import Data.String.Utils
|
import Data.String.Utils
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
|
@ -17,8 +16,10 @@ import qualified Annex
|
||||||
|
|
||||||
verbose :: Annex () -> Annex ()
|
verbose :: Annex () -> Annex ()
|
||||||
verbose a = do
|
verbose a = do
|
||||||
q <- Annex.getState Annex.quiet
|
output <- Annex.getState Annex.output
|
||||||
unless q a
|
case output of
|
||||||
|
Annex.NormalOutput -> a
|
||||||
|
_ -> return ()
|
||||||
|
|
||||||
showStart :: String -> String -> Annex ()
|
showStart :: String -> String -> Annex ()
|
||||||
showStart command file = verbose $ liftIO $ do
|
showStart command file = verbose $ liftIO $ do
|
||||||
|
|
|
@ -26,9 +26,9 @@ commonOptions =
|
||||||
"allow actions that may lose annexed data"
|
"allow actions that may lose annexed data"
|
||||||
, Option ['F'] ["fast"] (NoArg (setfast True))
|
, Option ['F'] ["fast"] (NoArg (setfast True))
|
||||||
"avoid slow operations"
|
"avoid slow operations"
|
||||||
, Option ['q'] ["quiet"] (NoArg (setquiet True))
|
, Option ['q'] ["quiet"] (NoArg (setoutput Annex.QuietOutput))
|
||||||
"avoid verbose output"
|
"avoid verbose output"
|
||||||
, Option ['v'] ["verbose"] (NoArg (setquiet False))
|
, Option ['v'] ["verbose"] (NoArg (setoutput Annex.NormalOutput))
|
||||||
"allow verbose output (default)"
|
"allow verbose output (default)"
|
||||||
, Option ['d'] ["debug"] (NoArg (setdebug))
|
, Option ['d'] ["debug"] (NoArg (setdebug))
|
||||||
"show debug messages"
|
"show debug messages"
|
||||||
|
@ -38,7 +38,7 @@ commonOptions =
|
||||||
where
|
where
|
||||||
setforce v = Annex.changeState $ \s -> s { Annex.force = v }
|
setforce v = Annex.changeState $ \s -> s { Annex.force = v }
|
||||||
setfast v = Annex.changeState $ \s -> s { Annex.fast = 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 }
|
setforcebackend v = Annex.changeState $ \s -> s { Annex.forcebackend = Just v }
|
||||||
setdebug = liftIO $ updateGlobalLogger rootLoggerName $
|
setdebug = liftIO $ updateGlobalLogger rootLoggerName $
|
||||||
setLevel DEBUG
|
setLevel DEBUG
|
||||||
|
|
Loading…
Reference in a new issue