org.nuisto.MuleLint.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mule-lint Show documentation
Show all versions of mule-lint Show documentation
An application to check for consistency in a mule application.
package org.nuisto
import groovy.util.logging.Slf4j
import org.nuisto.model.OptionsModel
@Slf4j(category = 'org.nuisto.msa')
class MuleLint {
static void main(String [] args) {
new MuleLint().run(args)
}
int run(String [] args) {
def cli = new CliBuilder(usage: 'mule-lint.groovy -[hdr] -s -r ')
// Create the list of options.
cli.with {
h longOpt: 'help', 'Show usage information'
r longOpt: 'rules', args: 1, argName: 'path', 'Required. The path to a set of rules.'
s longOpt: 'sources', args: 1, argName: 'sources', 'The directory name of where the source files are located, default: src/main'
o longOpt: 'output', args: 1, argName: 'path', 'The file name to write json results to.'
}
def options = cli.parse(args)
if (!options) {
return
}
// Show usage text when -h or --help option is used.
if (options.h) {
cli.usage()
return
}
def optionsModel = new OptionsModel()
if (!options.r) {
log.error 'Rules must be provided'
System.exit(ErrorCodes.RulesNotProvided)
}
else {
optionsModel.rules = options.r
}
if (options.s) {
optionsModel.sourceDirectory = options.s
}
else {
optionsModel.sourceDirectory = 'src/main'
}
if (options.o) {
optionsModel.resultsFile = options.o
}
runWithModel(optionsModel)
}
int invoke(String rules, String sourceDirectory, Map namespaces) {
OptionsModel optionsModel = new OptionsModel(rules: rules, sourceDirectory: sourceDirectory, namespaces: namespaces)
return runWithModel(optionsModel)
}
int runWithModel(OptionsModel model) {
return new Runner().runWithModel(model)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy