Extract error headers

This commit is contained in:
Joshua Clayton 2016-06-23 22:44:23 -04:00
parent b65de02efc
commit 1892f8c0ba
4 changed files with 21 additions and 15 deletions

View File

@ -0,0 +1,15 @@
module Unused.CLI.Views.Error
( errorHeader
) where
import Unused.CLI.Util
errorHeader :: String -> IO ()
errorHeader s = do
setSGR [SetColor Background Vivid Red]
setSGR [SetColor Foreground Vivid White]
setSGR [SetConsoleIntensity BoldIntensity]
putStrLn $ "\n" ++ s ++ "\n"
setSGR [Reset]

View File

@ -3,17 +3,12 @@ module Unused.CLI.Views.InvalidConfigError
) where
import Unused.CLI.Util
import Unused.CLI.Views.Error
import Unused.ResultsClassifier (ParseConfigError(..))
invalidConfigError :: [ParseConfigError] -> IO ()
invalidConfigError es = do
setSGR [SetColor Background Vivid Red]
setSGR [SetColor Foreground Vivid White]
setSGR [SetConsoleIntensity BoldIntensity]
putStrLn "\nThere was a problem with the following config file(s):\n"
setSGR [Reset]
errorHeader "There was a problem with the following config file(s):"
mapM_ configError es

View File

@ -4,18 +4,13 @@ module Unused.CLI.Views.MissingTagsFileError
import Unused.TagsSource
import Unused.CLI.Util
import Unused.CLI.Views.Error
missingTagsFileError :: TagSearchOutcome -> IO ()
missingTagsFileError e = do
setSGR [SetColor Background Vivid Red]
setSGR [SetColor Foreground Vivid White]
setSGR [SetConsoleIntensity BoldIntensity]
putStrLn "\nThere was a problem finding a tags file.\n"
setSGR [Reset]
errorHeader "There was a problem finding a tags file."
printOutcomeMessage e
putStr "\n"
setSGR [SetConsoleIntensity BoldIntensity]

View File

@ -42,6 +42,7 @@ library
, Unused.CLI.GitContext
, Unused.CLI.Util
, Unused.CLI.Views
, Unused.CLI.Views.Error
, Unused.CLI.Views.NoResultsFound
, Unused.CLI.Views.AnalysisHeader
, Unused.CLI.Views.GitSHAsHeader