mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 01:11:38 +08:00
Removed jsoncheck. Use 'shellcheck -f json -' instead
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user