Permalink
Browse files

ENH No colour output when NO_COLOR is defined

  • Loading branch information...
luispedro committed Oct 28, 2018
1 parent 92a7841 commit 15926150701100ff96b4a7cd1f3142f9a272b983
Showing with 5 additions and 2 deletions.
  1. +1 −0 ChangeLog
  2. +4 −2 NGLess/Output.hs
View
@@ -11,6 +11,7 @@ Version 0.9.1+
* Add __extra_megahit_args to assemble() (issue #86)
* Better error message when user mis-specifies the ngless version string
(issue #84)
* Support NO_COLOR environment variable (issue #83)
Version 0.9.1 2018-07-17 by luispedro
* Add biorxiv citation
View
@@ -22,7 +22,7 @@ import Text.Printf (printf)
import System.IO (hIsTerminalDevice, stdout)
import System.IO.Unsafe (unsafePerformIO)
import System.IO.SafeWrite (withOutputFile)
import Data.Maybe (maybeToList, fromMaybe)
import Data.Maybe (maybeToList, fromMaybe, isJust)
import Data.IORef (IORef, newIORef, modifyIORef, readIORef)
import Data.List (sort)
import Data.Aeson ((.=))
@@ -45,6 +45,7 @@ import qualified Data.ByteString.Lazy.Char8 as BL8
import qualified Data.ByteString.Lazy as BL
import qualified Graphics.Rendering.Chart.Easy as G
import qualified Graphics.Rendering.Chart.Backend.Cairo as G
import System.Environment (lookupEnv)
import Data.FastQ (FastQEncoding(..), encodingName)
@@ -175,14 +176,15 @@ shouldPrint True ot Normal = ot >= InfoOutput
output :: OutputType -> Int -> String -> NGLessIO ()
output !ot !lno !msg = do
isTerm <- liftIO $ hIsTerminalDevice stdout
hasNOCOLOR <- isJust <$> liftIO (lookupEnv "NO_COLOR")
verb <- nConfVerbosity <$> nglConfiguration
traceSet <- nConfTrace <$> nglConfiguration
colorOpt <- nConfColor <$> nglConfiguration
let sp = traceSet || shouldPrint isTerm ot verb
doColor = case colorOpt of
ForceColor -> True
NoColor -> False
AutoColor -> isTerm
AutoColor -> isTerm && not hasNOCOLOR
c <- colorFor ot
liftIO $ do
t <- getZonedTime

0 comments on commit 1592615

Please sign in to comment.