@@ -1,8 +1,9 @@
1module OpenAPI.Checker.Options
1module OpenAPI.Checker.Options
2− ( Options (..),
2+ ( Options (..)
3− Mode (..),
3+ , Mode (..)
4− optionsParserInfo,
5+ , optionsParserInfo
5− execParser,
6+ , execParser
@@ -10,52 +11,55 @@ import GHC.Generics (Generic)
10import Options.Applicative
11import Options.Applicative
12data Options = Options
13data Options = Options
13− { clientFile :: FilePath,
14+ { clientFile :: FilePath
14− serverFile :: FilePath,
15+ , serverFile :: FilePath
15− mode :: Mode
16+ , mode :: Mode
17+ , outputMode :: OutputMode
17 deriving stock (Generic)
19 deriving stock (Generic)
19data Mode = Silent | OnlyErrors | All
21data Mode = Silent | OnlyErrors | All
23+data OutputMode = StdoutMode | FileMode FilePath
21optionsParserInfo :: ParserInfo Options
25optionsParserInfo :: ParserInfo Options
22optionsParserInfo =
26optionsParserInfo =
24 (helper <*> optionsParser)
28 (helper <*> optionsParser)
25− ( fullDesc
29+ (fullDesc
26− <> header "openapi-diff"
30+ <> header "openapi-diff"
27− <> progDesc "A tool to check compatibility between two OpenApi specifications."
31+ <> progDesc "A tool to check compatibility between two OpenApi specifications.")
30optionsParser :: Parser Options
33optionsParser :: Parser Options
31optionsParser =
34optionsParser =
33 <$> strOption
36 <$> strOption
34− ( short 'c'
37+ (short 'c'
35− <> long "client"
38+ <> long "client"
36− <> help "The specification that will be used for the client of the API."
39+ <> help "The specification that will be used for the client of the API.")
38 <*> strOption
40 <*> strOption
39− ( short 's'
41+ (short 's'
40− <> long "server"
42+ <> long "server"
41− <> help "The specification that will be used for the server of the API."
43+ <> help "The specification that will be used for the server of the API.")
43− <*> ( flag'
44+ <*> (flag'
45− ( long "silent"
46+ (long "silent"
46− <> help "Silence all output."
47+ <> help "Silence all output.")
48− <|> flag'
48+ <|> flag'
49− OnlyErrors
49+ OnlyErrors
50− ( long "only-errors"
50+ (long "only-errors"
51− <> help "Only report incompatibility errors in the output."
51+ <> help "Only report incompatibility errors in the output.")
53− <|> flag'
52+ <|> flag'
55− ( long "all"
54+ (long "all"
57− "Report both incompatible and compatible changes. \
56+ "Report both incompatible and compatible changes. \
58− \Compatible changes will not trigger a failure exit code."
57+ \Compatible changes will not trigger a failure exit code.")
60− <|> pure All
58+ <|> pure All)
61− )
59+ <*> (pure StdoutMode
62+ (short 'o' <> long "output"
64+ "The file path where the output should be writtrn. \
65+ \Leave blank to output result to stdout.")))