mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 10:12:50 +08:00
Add command-line option -S/--severity
Specifies the maximum severity of errors to handle. For example, specifying "-S warning" means that errors of severity "info" and "style" are ignored. Signed-off-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
committed by
Vidar Holen
parent
15aaacf715
commit
b16da4b242
@@ -67,7 +67,8 @@ instance Monoid Status where
|
||||
data Options = Options {
|
||||
checkSpec :: CheckSpec,
|
||||
externalSources :: Bool,
|
||||
formatterOptions :: FormatterOptions
|
||||
formatterOptions :: FormatterOptions,
|
||||
maxSeverity :: Severity
|
||||
}
|
||||
|
||||
defaultOptions = Options {
|
||||
@@ -75,7 +76,8 @@ defaultOptions = Options {
|
||||
externalSources = False,
|
||||
formatterOptions = FormatterOptions {
|
||||
foColorOption = ColorAuto
|
||||
}
|
||||
},
|
||||
maxSeverity = StyleC
|
||||
}
|
||||
|
||||
usageHeader = "Usage: shellcheck [OPTIONS...] FILES..."
|
||||
@@ -93,6 +95,9 @@ options = [
|
||||
Option "s" ["shell"]
|
||||
(ReqArg (Flag "shell") "SHELLNAME")
|
||||
"Specify dialect (sh, bash, dash, ksh)",
|
||||
Option "S" ["severity"]
|
||||
(ReqArg (Flag "severity") "SEVERITY")
|
||||
"Maximum severity of errors to consider (error, warning, info, style)",
|
||||
Option "V" ["version"]
|
||||
(NoArg $ Flag "version" "true") "Print version information",
|
||||
Option "x" ["external-sources"]
|
||||
@@ -223,6 +228,14 @@ parseColorOption colorOption =
|
||||
"never" -> ColorNever
|
||||
_ -> error $ "Bad value for --color `" ++ colorOption ++ "'"
|
||||
|
||||
parseSeverityOption severityOption =
|
||||
case severityOption of
|
||||
"error" -> ErrorC
|
||||
"warning" -> WarningC
|
||||
"info" -> InfoC
|
||||
"style" -> StyleC
|
||||
_ -> error $ "Bad value for --severity `" ++ severityOption ++ "'"
|
||||
|
||||
parseOption flag options =
|
||||
case flag of
|
||||
Flag "shell" str ->
|
||||
@@ -266,6 +279,13 @@ parseOption flag options =
|
||||
}
|
||||
}
|
||||
|
||||
Flag "severity" severity ->
|
||||
return options {
|
||||
checkSpec = (checkSpec options) {
|
||||
csMaxSeverity = parseSeverityOption severity
|
||||
}
|
||||
}
|
||||
|
||||
_ -> return options
|
||||
where
|
||||
die s = do
|
||||
|
Reference in New Issue
Block a user