@@ -1,8 +1,7 @@
1module OpenAPI.Checker.Options
1module OpenAPI.Checker.Options
2 ( Options (..)
2 ( Options (..)
3 , OutputMode (..)
3 , OutputMode (..)
4− , optionsParserInfo
4+ , parseOptions
@@ -11,6 +10,9 @@ import OpenAPI.Checker.Report
11import Options.Applicative
10import Options.Applicative
12import Options.Applicative.Help hiding (fullDesc)
11import Options.Applicative.Help hiding (fullDesc)
13+parseOptions :: IO Options
14+parseOptions = customExecParser (prefs $ showHelpOnError) optionsParserInfo
14data Options = Options
16data Options = Options
15 { clientFile :: FilePath
17 { clientFile :: FilePath
16 , serverFile :: FilePath
18 , serverFile :: FilePath
@@ -18,6 +20,7 @@ data Options = Options
18 mode :: Maybe ReportMode
20 mode :: Maybe ReportMode
19 , outputMode :: OutputMode
21 , outputMode :: OutputMode
20 , reportTreeStyle :: ReportTreeStyle
22 , reportTreeStyle :: ReportTreeStyle
23+ , signalExitCode :: Bool
22 deriving stock (Generic)
25 deriving stock (Generic)
@@ -62,7 +65,7 @@ optionsParser =
62 <*> (flag'
65 <*> (flag'
64 (long "silent"
67 (long "silent"
65− <> help "Silence all output.")
68+ <> help "Silence all output. Only makes sense in combination with --signal-exit-code.")
67 (Just OnlyErrors)
70 (Just OnlyErrors)
68 (long "only-breaking"
71 (long "only-breaking"
@@ -100,6 +103,13 @@ optionsParser =
100 "The report tree is structured using \
103 "The report tree is structured using \
101 \increasing levels of headers.")
104 \increasing levels of headers.")
102 <|> pure HeadersTreeStyle)
105 <|> pure HeadersTreeStyle)
107+ (long "signal-exit-code"
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."))
104par :: String -> Doc
114par :: String -> Doc
105par = foldr1 (</>) . fmap string . words
115par = foldr1 (</>) . fmap string . words