@@ -0,0 +1,61 @@
1+module OpenAPI.Checker.Options
2+ ( Options (..),
3+ Mode (..),
4+ optionsParserInfo,
5+ execParser,
6+ )
7+where
8+
9+import GHC.Generics (Generic)
10+import Options.Applicative
11+
12+data Options = Options
13+ { clientFile :: FilePath,
14+ serverFile :: FilePath,
15+ mode :: Mode
16+ }
17+ deriving stock (Generic)
18+
19+data Mode = Silent | OnlyErrors | All
20+
21+optionsParserInfo :: ParserInfo Options
22+optionsParserInfo =
23+ info
24+ (helper <*> optionsParser)
25+ ( fullDesc
26+ <> header "openapi-diff"
27+ <> progDesc "A tool to check compatibility between two OpenApi specifications."
28+ )
29+
30+optionsParser :: Parser Options
31+optionsParser =
32+ Options
33+ <$> strOption
34+ ( short 'c'
35+ <> long "client"
36+ <> help "The specification that will be used for the client of the API."
37+ )
38+ <*> 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+ )