@@ -1,8 +1,7 @@
11module OpenAPI.Checker.Options
22 ( Options (..)
33 , OutputMode (..)
4− , optionsParserInfo
5− , execParser
4+ , parseOptions
65 )
76where
87
@@ -11,6 +10,9 @@ import OpenAPI.Checker.Report
1110import Options.Applicative
1211import Options.Applicative.Help hiding (fullDesc)
1312
13+parseOptions :: IO Options
14+parseOptions = customExecParser (prefs $ showHelpOnError) optionsParserInfo
15+
1416data Options = Options
1517 { clientFile :: FilePath
1618 , serverFile :: FilePath
@@ -18,6 +20,7 @@ data Options = Options
1820 mode :: Maybe ReportMode
1921 , outputMode :: OutputMode
2022 , reportTreeStyle :: ReportTreeStyle
23+ , signalExitCode :: Bool
2124 }
2225 deriving stock (Generic)
2326
@@ -62,7 +65,7 @@ optionsParser =
6265 <*> (flag'
6366 Nothing
6467 (long "silent"
65− <> help "Silence all output.")
68+ <> help "Silence all output. Only makes sense in combination with --signal-exit-code.")
6669 <|> flag'
6770 (Just OnlyErrors)
6871 (long "only-breaking"
@@ -100,6 +103,13 @@ optionsParser =
100103 "The report tree is structured using \
101104 \increasing levels of headers.")
102105 <|> pure HeadersTreeStyle)
106+ <*> switch
107+ (long "signal-exit-code"
108+ <> helpDoc (Just $
109+ par "Signal API compatibility with the exit code."
110+ <$$> hardline <> par "Exit with 0 if there are no breaking changes."
111+ <$$> par "Exit with 1 if there are breaking changes."
112+ <$$> par "Exit with 2 if could not determine compatibility."))
103113
104114par :: String -> Doc
105115par = foldr1 (</>) . fmap string . words