avoid showing json lists of remotes when not in json mode

This commit is contained in:
Joey Hess 2011-09-02 16:44:04 -04:00
parent cb5dacfd40
commit d1dd40c49b
3 changed files with 15 additions and 6 deletions

View file

@ -19,12 +19,14 @@ module Messages (
showErr,
warning,
indent,
maybeShowJSON,
setupConsole
) where
import Control.Monad.State (liftIO)
import System.IO
import Data.String.Utils
import Text.JSON
import Types
import qualified Annex
@ -106,5 +108,9 @@ handle json normal = do
Annex.QuietOutput -> q
Annex.JSONOutput -> liftIO json
{- Shows a JSON value only when in json mode. -}
maybeShowJSON :: JSON a => [(String, a)] -> Annex ()
maybeShowJSON v = handle (JSON.add v) q
q :: Monad m => m ()
q = return ()