Skip to content

Commit

Permalink
#318 Get HSC version from ProductInformation
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Oct 8, 2024
1 parent 14fb79e commit 024f5f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand All @@ -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"

Expand Down Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"() {
Expand Down

0 comments on commit 024f5f3

Please sign in to comment.