diff options
-rw-r--r-- | app/Main.hs | 14 | ||||
-rw-r--r-- | tests/expect | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/app/Main.hs b/app/Main.hs index 60c81e4..151115e 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,5 +1,6 @@ {-# LANGUAGE BlockArguments #-} {-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PartialTypeSignatures #-} @@ -58,7 +59,7 @@ import Issue.Tag qualified as I import Options.Applicative ((<**>)) import Options.Applicative qualified as O import Prettyprinter qualified as P -import Prettyprinter.Render.Terminal as P +import Prettyprinter.Render.Terminal qualified as P import System.Exit (ExitCode (ExitFailure), exitWith) import System.FilePath qualified as F import System.IO (hPutStrLn, stderr) @@ -125,7 +126,7 @@ main = do showMatches :: [Issue] -> IO () showMatches issues = do - P.putDoc . P.vsep $ + putDoc . P.vsep $ map ( \issue -> P.vsep @@ -141,7 +142,7 @@ showMatches issues = do listMatches :: [Issue] -> IO () listMatches issues = - P.putDoc . P.vsep $ + putDoc . P.vsep $ map ( \issue -> P.hsep @@ -158,6 +159,13 @@ listMatches issues = ) issues +putDoc :: P.Doc P.AnsiStyle -> IO () +putDoc doc = do + isTty <- (== 1) <$> c_isatty 1 + P.putDoc . (if isTty then id else P.unAnnotate) $ doc + +foreign import ccall "unistd.h isatty" c_isatty :: Int -> IO Int + data UnknownFileExtension = UnknownFileExtension { extension :: String } diff --git a/tests/expect b/tests/expect index b6ec25f..61fef67 100644 --- a/tests/expect +++ b/tests/expect @@ -1,2 +1,2 @@ add more dependencies -remove unnecessary content +remove unnecessary content
\ No newline at end of file |