-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
plugins { | ||
id 'application' | ||
} | ||
|
||
dependencies { | ||
implementation 'info.picocli:picocli:4.7.5' | ||
annotationProcessor 'info.picocli:picocli-codegen:4.7.5' | ||
|
||
implementation "org.slf4j:slf4j-api:2.0.7" | ||
implementation "org.slf4j:slf4j-simple:2.0.7" | ||
implementation "org.codehaus.groovy:groovy-all:3.0.17" | ||
|
||
implementation project(":htmlSanityCheck-core") | ||
} | ||
|
||
compileGroovy { | ||
options.compilerArgs += ["-Aproject=${project.group}/${project.name}"] | ||
} | ||
|
||
application { | ||
mainClass = 'org.aim42.htmlsanitycheck.cli.Main' | ||
} |
86 changes: 86 additions & 0 deletions
86
htmlSanityCheck-cli/src/main/groovy/org/aim42/htmlsanitycheck/cli/Main.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package org.aim42.htmlsanitycheck.cli | ||
|
||
import org.aim42.htmlsanitycheck.AllChecksRunner | ||
import org.aim42.htmlsanitycheck.Configuration | ||
import org.slf4j.Logger | ||
import org.slf4j.LoggerFactory | ||
import picocli.CommandLine | ||
import picocli.CommandLine.Command | ||
import picocli.CommandLine.Option | ||
|
||
// see end-of-file for license information | ||
|
||
@Command(name = "hsc", mixinStandardHelpOptions = true, version = "hsc 2.0.0", | ||
description = "Check HTML files for Sanity") | ||
class Main implements Runnable { | ||
private static final Logger logger = LoggerFactory.getLogger(Main.class) | ||
|
||
// @Option(names = ["-h", "--help"], usageHelp = true, description = "Display help message") | ||
// void help () { | ||
// logger.info("""SYNOPSIS: htmlSanityCheck | ||
// "-s sourceDir | ||
// "[ -f sourceFile ]+ | ||
// "-r resultsDir""") | ||
// } | ||
|
||
@Option(names = ["-s", "--sourceDir"], description = "Source Directory") | ||
String sourceDirectoryName | ||
|
||
@Option(names = ["-f", "--sourceFile"], description = "Source Directory", arity = "*") | ||
String[] sourceFileNames | ||
|
||
@Option(names = ["-r", "--resultsDir"], description = "Results Directory") | ||
String resultsDirectoryName = "/tmp/results" | ||
|
||
static void main(String[] args) { | ||
Main app = new Main() | ||
CommandLine cmd = new CommandLine(app) | ||
cmd.execute(args) | ||
} | ||
|
||
void run() { | ||
var configuration = new Configuration() | ||
|
||
var resultsDirectory = new File(resultsDirectoryName) | ||
|
||
configuration.addConfigurationItem(Configuration.ITEM_NAME_sourceDir, new File(sourceDirectoryName)) | ||
configuration.addConfigurationItem(Configuration.ITEM_NAME_sourceDocuments, | ||
sourceFileNames.collect {filename -> | ||
return new File(filename) | ||
} | ||
) | ||
configuration.addConfigurationItem((Configuration.ITEM_NAME_checkingResultsDir), resultsDirectory) | ||
|
||
if (configuration.isValid()) { | ||
// create output directory for checking results | ||
resultsDirectory.mkdirs() | ||
|
||
// create an AllChecksRunner... | ||
var allChecksRunner = new AllChecksRunner(configuration) | ||
|
||
// ... and perform the actual checks | ||
var allChecks = allChecksRunner.performAllChecks() | ||
|
||
// check for findings and fail build if requested | ||
var nrOfFindingsOnAllPages = allChecks.nrOfFindingsOnAllPages() | ||
logger.debug("Found ${nrOfFindingsOnAllPages} error(s) on all checked pages") | ||
} | ||
} | ||
} | ||
|
||
/*======================================================================== | ||
Copyright Gerd Aschemann and aim42 contributors | ||
Licensed under the Apache License, Version 2.0 (the "License") | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an | ||
"AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
========================================================================*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters