提交 2e13cedc 编写于 作者: V Vidar Holen

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

上级 17515ad7
......@@ -9,15 +9,12 @@ shellcheck: regardless
: Conditionally compiling shellcheck
ghc $(GHCFLAGS) --make shellcheck
jsoncheck: regardless
: Conditionally compiling shellcheck
ghc $(GHCFLAGS) --make jsoncheck
.tests: *.hs */*.hs
: Running unit tests
./test/runQuack && touch .tests
clean:
rm -f .tests dist shellcheck jsoncheck *.hi *.o ShellCheck/*.hi ShellCheck/*.o
rm -f .tests shellcheck *.hi *.o ShellCheck/*.hi ShellCheck/*.o
rm -rf dist
regardless:
......@@ -9,12 +9,8 @@ Build-Type: Simple
Cabal-Version: >= 1.2
library
build-depends: base >= 4, parsec, containers, regex-compat, mtl, directory
build-depends: base >= 4, parsec, containers, regex-compat, mtl, directory, json
exposed-modules: ShellCheck.AST, ShellCheck.Data, ShellCheck.Parser, ShellCheck.Analytics, ShellCheck.Simple
executable shellcheck
main-is: shellcheck.hs
executable jsoncheck
build-depends: json
main-is: jsoncheck.hs
{-
This file is part of ShellCheck.
http://www.vidarholen.net/contents/shellcheck
ShellCheck is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ShellCheck is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-}
import ShellCheck.Simple
import Text.JSON
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
main = do
script <- getContents
putStrLn $ encodeStrict $ shellCheck script
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册