Add initial support for --color

This commit is contained in:
David Haguenauer
2015-12-03 11:15:32 -05:00
parent bd359c5c0f
commit a3d4101d6c
4 changed files with 40 additions and 8 deletions

View File

@@ -59,7 +59,8 @@ instance Monoid Status where
data Options = Options {
checkSpec :: CheckSpec,
externalSources :: Bool
externalSources :: Bool,
color :: ColorOptions
}
defaultOptions = Options {
@@ -73,6 +74,8 @@ options = [
(ReqArg (Flag "exclude") "CODE1,CODE2..") "exclude types of warnings",
Option "f" ["format"]
(ReqArg (Flag "format") "FORMAT") "output format",
Option "C" ["color"]
(ReqArg (Flag "color") "WHEN") "Set use of color (auto, always, never)",
Option "s" ["shell"]
(ReqArg (Flag "shell") "SHELLNAME") "Specify dialect (sh,bash,dash,ksh)",
Option "x" ["external-sources"]
@@ -195,6 +198,13 @@ runFormatter sys format options files = do
then NoProblems
else SomeProblems
parseColorOption colorOption =
case colorOption of
"auto" -> ColorAuto
"always" -> ColorAlways
"never" -> ColorNever
_ -> error $ "Bad value for --color `" ++ colorOption ++ "'"
parseOption flag options =
case flag of
Flag "shell" str ->
@@ -224,6 +234,13 @@ parseOption flag options =
externalSources = True
}
Flag "color" color ->
return options {
checkSpec = (checkSpec options) {
csColorOption = parseColorOption color
}
}
_ -> return options
where
die s = do