Removed jsoncheck. Use 'shellcheck -f json -' instead

This commit is contained in:
Vidar Holen
2013-11-12 21:39:41 -08:00
parent 17515ad706
commit 2e13cedc4b
4 changed files with 25 additions and 43 deletions

View File

@@ -24,6 +24,7 @@ import System.Directory
import System.Environment
import System.Exit
import System.IO
import Text.JSON
import qualified Data.Map as Map
data Flag = Flag String String
@@ -36,6 +37,16 @@ options = [
printErr = hPutStrLn stderr
instance JSON ShellCheckComment where
showJSON c = makeObj [
("line", showJSON $ scLine c),
("column", showJSON $ scColumn c),
("level", showJSON $ scSeverity c),
("code", showJSON $ scCode c),
("message", showJSON $ scMessage c)
]
readJSON = undefined
parseArguments argv =
case getOpt Permute options argv of
(opts, files, []) ->
@@ -55,6 +66,7 @@ parseArguments argv =
specials x = x
formats = Map.fromList [
("json", forJson),
("tty", forTty)
]
@@ -114,6 +126,16 @@ forTty options files = do
term <- hIsTerminalDevice stdout
return $ if term then colorComment else const id
-- This totally ignores the filenames. Fixme?
forJson options files = do
comments <- liftM concat $ mapM process files
putStrLn $ encodeStrict $ comments
return . null $ comments
where
process file = do
script <- readFile file
return $ shellCheck script
getOption [] _ def = def
getOption ((Flag var val):_) name _ | name == var = val
getOption (_:rest) flag def = getOption rest flag def