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