From ce92be6fb24c9f66f5eda53e98171b3479cb8df7 Mon Sep 17 00:00:00 2001 From: Gerd Aschemann Date: Wed, 21 Aug 2024 15:50:19 +0200 Subject: [PATCH] #318 Rename Main to HscCommand --- htmlSanityCheck-cli/build.gradle | 2 +- .../cli/{Main.groovy => HscCommand.groovy} | 30 +++++++++---------- ...inCliSpec.groovy => HscCommandSpec.groovy} | 14 ++++----- 3 files changed, 22 insertions(+), 24 deletions(-) rename htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/{Main.groovy => HscCommand.groovy} (85%) rename htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/{MainCliSpec.groovy => HscCommandSpec.groovy} (91%) diff --git a/htmlSanityCheck-cli/build.gradle b/htmlSanityCheck-cli/build.gradle index 39228666..67e4a02e 100644 --- a/htmlSanityCheck-cli/build.gradle +++ b/htmlSanityCheck-cli/build.gradle @@ -22,7 +22,7 @@ compileGroovy { } application { - mainClass = 'org.aim42.htmlsanitycheck.cli.Main' + mainClass = 'org.aim42.htmlsanitycheck.cli.HscCommand' applicationName = 'hsc' } diff --git a/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy b/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/HscCommand.groovy similarity index 85% rename from htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy rename to htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/HscCommand.groovy index e134b041..54624117 100644 --- a/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy +++ b/htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/HscCommand.groovy @@ -20,12 +20,12 @@ import java.nio.file.Paths description = "Check HTML files for Sanity", showDefaultValues = true ) -class Main implements Runnable { - private static final Logger logger = LoggerFactory.getLogger(Main.class) +class HscCommand implements Runnable { + private static final Logger logger = LoggerFactory.getLogger(HscCommand.class) - MainRunner runner + HscRunner runner - protected Main(MainRunner runner) { + protected HscCommand(HscRunner runner) { this.runner = runner } @@ -48,11 +48,11 @@ class Main implements Runnable { File[] srcDocs static void main(String[] args) { - MainRunner mainRunner = new MainRunner() - Main main = new Main(mainRunner) - CommandLine cmd = new CommandLine(main) - mainRunner.setMain(main) - mainRunner.setCmd(cmd) + HscRunner hscRunner = new HscRunner() + HscCommand hscCommand = new HscCommand(hscRunner) + CommandLine cmd = new CommandLine(hscCommand) + hscRunner.setHscCommand(hscCommand) + hscRunner.setCmd(cmd) cmd.execute(args) } @@ -65,27 +65,27 @@ class Main implements Runnable { .collect { it.toFile() } } - static class MainRunner { + static class HscRunner { - Main main + HscCommand hscCommand CommandLine cmd void run() { - if (main.versionRequested) { + if (hscCommand.versionRequested) { System.out.println("Version: ${ProductInformation.VERSION}") return } - def srcDocuments = main.srcDocs ?: main.findFiles() + def srcDocuments = hscCommand.srcDocs ?: hscCommand.findFiles() if (!srcDocuments) { System.err.println("Please specify at least one src document (either explicitly or implicitly)") cmd.usage(System.out) System.exit(1) } - var resultsDirectory = new File(main.resultsDirectoryName) + var resultsDirectory = new File(hscCommand.resultsDirectoryName) var configuration = Configuration.builder() - .sourceDir(main.srcDir) + .sourceDir(hscCommand.srcDir) .sourceDocuments(srcDocuments as Set) .checkingResultsDir(resultsDirectory) .checksToExecute(AllCheckers.CHECKER_CLASSES) diff --git a/htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/MainCliSpec.groovy b/htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/HscCommandSpec.groovy similarity index 91% rename from htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/MainCliSpec.groovy rename to htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/HscCommandSpec.groovy index 52dc99ca..d11038ab 100644 --- a/htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/MainCliSpec.groovy +++ b/htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/HscCommandSpec.groovy @@ -6,9 +6,7 @@ import picocli.CommandLine import spock.lang.Specification import spock.lang.Unroll -import java.nio.file.Files - -class MainCliSpec extends Specification { +class HscCommandSpec extends Specification { private final static VALID_HTML = """""" private final static INVALID_HTML = """ """ @@ -38,8 +36,8 @@ class MainCliSpec extends Specification { @Unroll def "test hsc with #args"() { given: - Main.MainRunner myAppRunner = Mock(Main.MainRunner) - def cmdLine = new CommandLine(new Main(myAppRunner)) + HscCommand.HscRunner myAppRunner = Mock(HscCommand.HscRunner) + def cmdLine = new CommandLine(new HscCommand(myAppRunner)) when: def exitCode = cmdLine.execute(args.split()) @@ -65,7 +63,7 @@ class MainCliSpec extends Specification { String[] args = ["-h"] when: - Main.main(args) + HscCommand.main(args) then: errContent.toString().contains("Usage: hsc") @@ -82,7 +80,7 @@ class MainCliSpec extends Specification { String[] args = [testProjectDir.getRoot()] when: - Main.main(args) + HscCommand.main(args) then: mockSecurityManager.exitCalled == 1 @@ -99,7 +97,7 @@ class MainCliSpec extends Specification { String[] args = [testProjectDir.getRoot()] when: - Main.main(args) + HscCommand.main(args) then: outContent.toString().contains("found 0 issue, 100% successful.")