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 8eb7bd06..e134b041 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 @@ -2,6 +2,7 @@ package org.aim42.htmlsanitycheck.cli import org.aim42.htmlsanitycheck.AllChecksRunner import org.aim42.htmlsanitycheck.Configuration +import org.aim42.htmlsanitycheck.ProductInformation import org.aim42.htmlsanitycheck.check.AllCheckers import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -16,7 +17,6 @@ import java.nio.file.Paths // see end-of-file for license information @Command(name = "hsc", mixinStandardHelpOptions = true, - version = "hsc 2.0.0", description = "Check HTML files for Sanity", showDefaultValues = true ) @@ -29,6 +29,9 @@ class Main implements Runnable { this.runner = runner } + @Option(names = ["-V", "--version"], description = "Display version information") + boolean versionRequested + @Option(names = ["-r", "--resultsDir"], description = "Results Directory") String resultsDirectoryName = "/tmp/results" @@ -68,6 +71,11 @@ class Main implements Runnable { CommandLine cmd void run() { + if (main.versionRequested) { + System.out.println("Version: ${ProductInformation.VERSION}") + return + } + def srcDocuments = main.srcDocs ?: main.findFiles() if (!srcDocuments) { System.err.println("Please specify at least one src document (either explicitly or implicitly)") diff --git a/htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/MainCliSpec.groovy b/htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/MainCliSpec.groovy index 4d3b67b9..52dc99ca 100644 --- a/htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/MainCliSpec.groovy +++ b/htmlSanityCheck-cli/src/test/groovy/org/aim42/htmlsanitycheck/cli/MainCliSpec.groovy @@ -50,10 +50,10 @@ class MainCliSpec extends Specification { where: args | expectedExitCode | runnerWasCalled - "-h" | 0 | false - "--help" | 0 | false - "-V" | 0 | false - "--version" | 0 | false + "-h" | 2 | false + "--help" | 2 | false + "-V" | 0 | true + "--version" | 0 | true "" | 0 | true "." | 0 | true "-r /tmp/results" | 0 | true @@ -68,8 +68,8 @@ class MainCliSpec extends Specification { Main.main(args) then: - outContent.toString().contains("Usage: hsc") - outContent.toString().contains("Check HTML files for Sanity") + errContent.toString().contains("Usage: hsc") + errContent.toString().contains("Check HTML files for Sanity") } def "test with empty source directory"() {