From 0871c7b33c0b1ab65eea6ccb42d47981acfffde3 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Tue, 1 Jun 2021 08:39:22 +0200 Subject: [PATCH] [jOOQ/jOOQ#11932] CLI APIs should log more helpful error messages on NoClassDefFoundError --- jOOQ/src/main/java/org/jooq/DiffCLI.java | 29 +++++++++--------- jOOQ/src/main/java/org/jooq/ParserCLI.java | 35 +++++++++++----------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/DiffCLI.java b/jOOQ/src/main/java/org/jooq/DiffCLI.java index c29de93fa8..40a1cf237a 100644 --- a/jOOQ/src/main/java/org/jooq/DiffCLI.java +++ b/jOOQ/src/main/java/org/jooq/DiffCLI.java @@ -51,22 +51,23 @@ import org.jooq.impl.DSL; public final class DiffCLI { public static final void main(String... args) throws Exception { - Args a; - Settings settings = new Settings(); - DSLContext ctx; + CLIUtil.main("https://www.jooq.org/doc/latest/manual/sql-building/schema-diff-cli/", () -> { + Args a; + Settings settings = new Settings(); + DSLContext ctx; - a = parse(args); - settings(a, settings); - ctx = ctx(a, settings); + a = parse(args); + settings(a, settings); + ctx = ctx(a, settings); - if (a.done) {} - else if (a.toDialect == null || a.sql1 == null || a.sql2 == null) { - System.out.println("Mandatory arguments: -T and -1, -2. Use -h for help"); - throw new RuntimeException(); - } - else { - render(ctx, a); - } + if (a.done) {} + else if (a.toDialect == null || a.sql1 == null || a.sql2 == null) { + System.out.println("Mandatory arguments: -T and -1, -2. Use -h for help"); + throw new RuntimeException(); + } + else + render(ctx, a); + }); } private static final DSLContext ctx(Args a, Settings settings) { diff --git a/jOOQ/src/main/java/org/jooq/ParserCLI.java b/jOOQ/src/main/java/org/jooq/ParserCLI.java index 6f8dd063bb..7a22c0079e 100644 --- a/jOOQ/src/main/java/org/jooq/ParserCLI.java +++ b/jOOQ/src/main/java/org/jooq/ParserCLI.java @@ -64,25 +64,26 @@ public final class ParserCLI { private static final Pattern FLAG = Pattern.compile("^/([\\w\\-]+)(?:\\s+(\\w+))?\\s*$"); public static final void main(String... args) throws Exception { - Args a; - Settings settings = new Settings(); - DSLContext ctx; + CLIUtil.main("https://www.jooq.org/doc/latest/manual/sql-building/sql-parser/sql-parser-cli/", () -> { + Args a; + Settings settings = new Settings(); + DSLContext ctx; - a = parse(args); - settings(a, settings); - ctx = ctx(a, settings); + a = parse(args); + settings(a, settings); + ctx = ctx(a, settings); - if (a.interactive || args == null || args.length == 0) { - interactiveMode(ctx, a); - } - else if (a.done) {} - else if (a.toDialect == null || a.sql == null) { - System.out.println("Mandatory arguments: -T and -s. Use -h for help"); - throw new RuntimeException(); - } - else { - render(ctx, a); - } + if (a.interactive || args == null || args.length == 0) { + interactiveMode(ctx, a); + } + else if (a.done) {} + else if (a.toDialect == null || a.sql == null) { + System.out.println("Mandatory arguments: -T and -s. Use -h for help"); + throw new RuntimeException(); + } + else + render(ctx, a); + }); } private static final DSLContext ctx(Args a, Settings settings) {