hxtools/src-hxbrief/Util.hs

45 lines
1.3 KiB
Haskell

{-# OPTIONS_GHC -Wno-unused-imports #-}
module Util where
import Data.Text ( Text )
import qualified Data.Text as Text
import qualified System.Console.ANSI as Ansi
import System.Exit ( ExitCode
( ExitFailure
, ExitSuccess
)
)
t :: String -> Text
t = Text.pack
fGrey :: Text
fGrey =
t $ Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Dull Ansi.White]
fWhite :: Text
fWhite =
t $ Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Vivid Ansi.White]
fWhiteDis :: Text
fWhiteDis = t ""
fRedDis :: Text
fRedDis = t "" -- TODO disabled until the bug is fixed.
-- setFGColorDull Ansi.Red
fReset :: Text
fReset = t $ Ansi.setSGRCode [Ansi.Reset]
setFGColorVivid :: Ansi.Color -> Text
setFGColorVivid c =
t $ Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Vivid c]
setFGColorDull :: Ansi.Color -> Text
setFGColorDull c =
t $ Ansi.setSGRCode [Ansi.SetColor Ansi.Foreground Ansi.Dull c]
showEC :: ExitCode -> Text
showEC = \case
ExitSuccess -> setFGColorVivid Ansi.Green <> t "0" <> fReset
ExitFailure i -> setFGColorVivid Ansi.Red <> t (show i) <> fReset