More discriminating error codes
This commit is contained in:
parent
68cc00b6e8
commit
01d557abe6
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue