Skip to content

Commit

Permalink
[kowainik#34] Write errorMessage to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
sras committed Jun 19, 2020
1 parent 69af0b3 commit 358594b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Colourista/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ module Colourista.IO
, italicMessage
-- * General purpose
, formattedMessage
, formattedErrorMessage
) where

#if __GLASGOW_HASKELL__ < 804
import Data.Semigroup (Semigroup (..))
#endif
import Data.Text (Text)
import System.IO (stderr)

import qualified Data.Text.IO as TIO

Expand Down Expand Up @@ -126,7 +128,7 @@ warningMessage t = yellowMessage $ " ⚠ " <> t
<<https://user-images.githubusercontent.com/4276606/80867592-da0fcc80-8c8c-11ea-90e0-42aae8770c18.png Error message>>
-}
errorMessage :: Text -> IO ()
errorMessage t = redMessage $ " \128721 " <> t
errorMessage t = formattedErrorMessage [Colourista.red] $ " \128721 " <> t
{-# INLINE errorMessage #-}

----------------------------------------------------------------------------
Expand Down Expand Up @@ -156,3 +158,9 @@ list, no formatting is applied.
formattedMessage :: [Text] -> Text -> IO ()
formattedMessage formatting = TIO.putStrLn . Colourista.formatWith formatting
{-# INLINE formattedMessage #-}

{- | A variant of 'formattedMessage' that writes to 'stderr'
-}
formattedErrorMessage :: [Text] -> Text -> IO ()
formattedErrorMessage formatting = TIO.hPutStrLn stderr . Colourista.formatWith formatting
{-# INLINE formattedErrorMessage #-}

0 comments on commit 358594b

Please sign in to comment.