mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 04:45:28 +03:00
Extract error printing to separate function
This commit is contained in:
parent
8f5446a414
commit
6ee18cf1c9
38
app/Main.hs
38
app/Main.hs
@ -2,7 +2,7 @@ module Main where
|
|||||||
|
|
||||||
import System.Console.ANSI
|
import System.Console.ANSI
|
||||||
import Unused.TermSearch (search)
|
import Unused.TermSearch (search)
|
||||||
import Unused.Parser (parseLines)
|
import Unused.Parser (parseLines, ParseError)
|
||||||
import Unused.Types
|
import Unused.Types
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
@ -14,22 +14,8 @@ main = do
|
|||||||
case withOneOccurrence $ withOneFile response of
|
case withOneOccurrence $ withOneFile response of
|
||||||
Right termMatchSet ->
|
Right termMatchSet ->
|
||||||
mapM_ printMatchPair $ listFromMatchSet termMatchSet
|
mapM_ printMatchPair $ listFromMatchSet termMatchSet
|
||||||
Left e -> do
|
Left e ->
|
||||||
setSGR [SetColor Background Vivid Red]
|
printParseError e
|
||||||
setSGR [SetColor Foreground Vivid White]
|
|
||||||
setSGR [SetConsoleIntensity BoldIntensity]
|
|
||||||
|
|
||||||
putStrLn "\nThere was a problem parsing the data:\n"
|
|
||||||
|
|
||||||
setSGR [Reset]
|
|
||||||
|
|
||||||
setSGR [SetColor Foreground Vivid Red]
|
|
||||||
setSGR [SetConsoleIntensity BoldIntensity]
|
|
||||||
|
|
||||||
print e
|
|
||||||
putStr "\n"
|
|
||||||
|
|
||||||
setSGR [Reset]
|
|
||||||
|
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
@ -53,3 +39,21 @@ printMatches matches = do
|
|||||||
putStr $ " " ++ (show . occurrences) m ++ " "
|
putStr $ " " ++ (show . occurrences) m ++ " "
|
||||||
setSGR [Reset]
|
setSGR [Reset]
|
||||||
putStr "\n"
|
putStr "\n"
|
||||||
|
|
||||||
|
printParseError :: ParseError -> IO ()
|
||||||
|
printParseError e = do
|
||||||
|
setSGR [SetColor Background Vivid Red]
|
||||||
|
setSGR [SetColor Foreground Vivid White]
|
||||||
|
setSGR [SetConsoleIntensity BoldIntensity]
|
||||||
|
|
||||||
|
putStrLn "\nThere was a problem parsing the data:\n"
|
||||||
|
|
||||||
|
setSGR [Reset]
|
||||||
|
|
||||||
|
setSGR [SetColor Foreground Vivid Red]
|
||||||
|
setSGR [SetConsoleIntensity BoldIntensity]
|
||||||
|
|
||||||
|
print e
|
||||||
|
putStr "\n"
|
||||||
|
|
||||||
|
setSGR [Reset]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
module Unused.Parser
|
module Unused.Parser
|
||||||
( parseLines
|
( parseLines
|
||||||
|
, ParseError
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad (void)
|
import Control.Monad (void)
|
||||||
|
Loading…
Reference in New Issue
Block a user