Autogenerate list of formats for --help
This commit is contained in:
parent
72ed234291
commit
73d06c4f47
|
@ -35,6 +35,7 @@ import Data.Bits
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import Data.Functor
|
import Data.Functor
|
||||||
import Data.Either
|
import Data.Either
|
||||||
|
import Data.List
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
|
@ -77,8 +78,8 @@ options = [
|
||||||
Option "e" ["exclude"]
|
Option "e" ["exclude"]
|
||||||
(ReqArg (Flag "exclude") "CODE1,CODE2..") "exclude types of warnings",
|
(ReqArg (Flag "exclude") "CODE1,CODE2..") "exclude types of warnings",
|
||||||
Option "f" ["format"]
|
Option "f" ["format"]
|
||||||
(ReqArg (Flag "format") "FORMAT")
|
(ReqArg (Flag "format") "FORMAT") $
|
||||||
"output format (checkstyle, gcc, json, tty)",
|
"output format (" ++ formatList ++ ")",
|
||||||
Option "C" ["color"]
|
Option "C" ["color"]
|
||||||
(OptArg (maybe (Flag "color" "always") (Flag "color")) "WHEN")
|
(OptArg (maybe (Flag "color" "always") (Flag "color")) "WHEN")
|
||||||
"Use color (auto, always, never)",
|
"Use color (auto, always, never)",
|
||||||
|
@ -109,6 +110,10 @@ formats options = Map.fromList [
|
||||||
("tty", ShellCheck.Formatter.TTY.format options)
|
("tty", ShellCheck.Formatter.TTY.format options)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
formatList = intercalate ", " names
|
||||||
|
where
|
||||||
|
names = Map.keys $ formats (formatterOptions defaultOptions)
|
||||||
|
|
||||||
getOption [] _ = Nothing
|
getOption [] _ = Nothing
|
||||||
getOption (Flag var val:_) name | name == var = return val
|
getOption (Flag var val:_) name | name == var = return val
|
||||||
getOption (_:rest) flag = getOption rest flag
|
getOption (_:rest) flag = getOption rest flag
|
||||||
|
|
Loading…
Reference in New Issue