Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ usage: openapi-diff <old> <new>
output in file
--off No information printed
--query <property=value> use query param for authorisation
--state Only output diff state: no_changes,
incompatible, compatible
--trace be extra verbose
--version print the version information and exit
--warn Print warning information
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/qdesrame/openapi/diff/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static void main(String... args) {
Options options = new Options();
options.addOption(Option.builder("h").longOpt("help").desc("print this message").build());
options.addOption(Option.builder().longOpt("version").desc("print the version information and exit").build());
options.addOption(Option.builder().longOpt("state").desc("Only output diff state: no_changes, incompatible, compatible").build());
options.addOption(Option.builder().longOpt("trace").desc("be extra verbose").build());
options.addOption(Option.builder().longOpt("debug").desc("Print debugging information").build());
options.addOption(Option.builder().longOpt("info").desc("Print additional information").build());
Expand Down Expand Up @@ -81,6 +82,9 @@ public static void main(String... args) {
logLevel));
}
}
if (line.hasOption("state")) {
logLevel = "OFF";
}
LogManager.getRootLogger().setLevel(Level.toLevel(logLevel));

if (line.getArgList().size() < 2) {
Expand Down Expand Up @@ -126,7 +130,12 @@ public static void main(String... args) {
System.exit(2);
}
}
System.exit(result.isDiff() ? 1 : 0);
if (line.hasOption("state")) {
System.out.println(result.isDiff() ? result.isDiffBackwardCompatible() ? "compatible" : "incompatible" : "no_changes");
System.exit(0);
} else {
System.exit(result.isDiff() ? 1 : 0);
}
} catch (ParseException e) {
// oops, something went wrong
System.err.println("Parsing failed. Reason: " + e.getMessage());
Expand Down