From bb8ffa2463d70a89bbdee5eb6c24a4c7b8479e26 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Sat, 17 Aug 2024 12:12:56 +0200 Subject: [PATCH] #318 Drop (unnecessary) Factory --- .../org/aim42/htmlsanitycheck/cli/Main.groovy | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy b/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy index 09dcc169..8eb7bd06 100644 --- a/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy +++ b/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy @@ -25,11 +25,7 @@ class Main implements Runnable { MainRunner runner - Main() { - Main(new MainRunner()) - } - - Main(MainRunner runner) { + protected Main(MainRunner runner) { this.runner = runner } @@ -49,11 +45,11 @@ class Main implements Runnable { File[] srcDocs static void main(String[] args) { - MainRunner runner = new MainRunner() - Main app = new Main(runner) - CommandLine cmd = new CommandLine(app) - runner.setMain(app) - runner.setCmd(cmd) + MainRunner mainRunner = new MainRunner() + Main main = new Main(mainRunner) + CommandLine cmd = new CommandLine(main) + mainRunner.setMain(main) + mainRunner.setCmd(cmd) cmd.execute(args) } @@ -66,16 +62,7 @@ class Main implements Runnable { .collect { it.toFile() } } - static class MainRunner implements CommandLine.IFactory { - - @Override - T create(Class cls) throws Exception { - if (cls == Main.class) { - return (T) new Main() - } else { - throw new IllegalArgumentException("Cannot create CLI applications of class '${cls}'") - } - } + static class MainRunner { Main main CommandLine cmd