diff --git a/src/Unused/CLI/Views/Error.hs b/src/Unused/CLI/Views/Error.hs new file mode 100644 index 0000000..dbfe178 --- /dev/null +++ b/src/Unused/CLI/Views/Error.hs @@ -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] diff --git a/src/Unused/CLI/Views/InvalidConfigError.hs b/src/Unused/CLI/Views/InvalidConfigError.hs index 8126e15..44083fc 100644 --- a/src/Unused/CLI/Views/InvalidConfigError.hs +++ b/src/Unused/CLI/Views/InvalidConfigError.hs @@ -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 diff --git a/src/Unused/CLI/Views/MissingTagsFileError.hs b/src/Unused/CLI/Views/MissingTagsFileError.hs index 8cde5a4..9058b0f 100644 --- a/src/Unused/CLI/Views/MissingTagsFileError.hs +++ b/src/Unused/CLI/Views/MissingTagsFileError.hs @@ -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] diff --git a/unused.cabal b/unused.cabal index 72d5944..8763d97 100644 --- a/unused.cabal +++ b/unused.cabal @@ -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