mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-09-19 18:19:22 +08:00
More discriminating error codes
This commit is contained in:
@@ -38,6 +38,9 @@ options = [
|
|||||||
|
|
||||||
printErr = hPutStrLn stderr
|
printErr = hPutStrLn stderr
|
||||||
|
|
||||||
|
syntaxFailure = ExitFailure 3
|
||||||
|
supportFailure = ExitFailure 4
|
||||||
|
|
||||||
instance JSON ShellCheckComment where
|
instance JSON ShellCheckComment where
|
||||||
showJSON c = makeObj [
|
showJSON c = makeObj [
|
||||||
("line", showJSON $ scLine c),
|
("line", showJSON $ scLine c),
|
||||||
@@ -57,11 +60,11 @@ parseArguments argv =
|
|||||||
else do
|
else do
|
||||||
printErr "No files specified.\n"
|
printErr "No files specified.\n"
|
||||||
printErr $ usageInfo header options
|
printErr $ usageInfo header options
|
||||||
return $ Nothing
|
exitWith syntaxFailure
|
||||||
|
|
||||||
(_, _, errors) -> do
|
(_, _, errors) -> do
|
||||||
printErr $ (concat errors) ++ "\n" ++ usageInfo header options
|
printErr $ (concat errors) ++ "\n" ++ usageInfo header options
|
||||||
return Nothing
|
exitWith syntaxFailure
|
||||||
|
|
||||||
formats = Map.fromList [
|
formats = Map.fromList [
|
||||||
("json", forJson),
|
("json", forJson),
|
||||||
@@ -226,7 +229,7 @@ process (Just (options, files)) =
|
|||||||
printErr $ "Unknown format " ++ format
|
printErr $ "Unknown format " ++ format
|
||||||
printErr $ "Supported formats:"
|
printErr $ "Supported formats:"
|
||||||
mapM_ (printErr . write) $ Map.keys formats
|
mapM_ (printErr . write) $ Map.keys formats
|
||||||
return False
|
exitWith supportFailure
|
||||||
where write s = " " ++ s
|
where write s = " " ++ s
|
||||||
Just f -> do
|
Just f -> do
|
||||||
f options files
|
f options files
|
||||||
|
Reference in New Issue
Block a user