public class CommandLineRunner
extends java.lang.Object
class MyCommandLineRunner extends CommandLineRunner {
MyCommandLineRunner(String[] args) {
super(args);
}
@Override
protected CompilerOptions createOptions() {
CompilerOptions options = super.createOptions();
addMyCrazyCompilerPassThatOutputsAnExtraFile(options);
return options;
}
public static void main(String[] args) {
MyCommandLineRunner runner = new MyCommandLineRunner(args);
if (runner.shouldRunCompiler()) {
runner.run();
} else {
System.exit(-1);
}
}
}
This class is totally not thread-safe.Modifier and Type | Class and Description |
---|---|
static class |
AbstractCommandLineRunner.FlagUsageException
An exception thrown when command-line flags are used incorrectly.
|
protected static class |
AbstractCommandLineRunner.WarningGuardSpec
A little helper class to make it easier to collect warning types
from --jscomp_error, --jscomp_warning, and --jscomp_off.
|
Modifier | Constructor and Description |
---|---|
protected |
CommandLineRunner(java.lang.String[] args)
Create a new command-line runner.
|
protected |
CommandLineRunner(java.lang.String[] args,
java.io.PrintStream out,
java.io.PrintStream err) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkModuleName(java.lang.String name)
Validates the module name.
|
protected Compiler |
createCompiler()
Returns the instance of the Compiler to use when
run() is
called. |
protected java.util.List<SourceFile> |
createExterns() |
protected java.util.List<SourceFile> |
createInputs(java.util.List<java.lang.String> files,
boolean allowStdIn)
Creates inputs from a list of files.
|
protected CompilerOptions |
createOptions()
Returns the instance of the Options to use when
run() is called. |
protected int |
doRun()
Parses command-line arguments and runs the compiler.
|
protected java.io.OutputStream |
filenameToOutputStream(java.lang.String fileName)
Converts a file name into a Outputstream.
|
protected com.google.javascript.jscomp.AbstractCommandLineRunner.CommandLineConfig |
getCommandLineConfig()
Get the command line config, so that it can be initialized.
|
protected A |
getCompiler() |
static java.util.List<SourceFile> |
getDefaultExterns() |
protected DiagnosticGroups |
getDiagnosticGroups()
The warning classes that are available from the command-line.
|
protected java.io.PrintStream |
getErrorPrintStream()
Returns the PrintStream for writing errors associated with this
AbstractCommandLineRunner.
|
protected boolean |
isInTestMode()
Returns whether we're in test mode.
|
static void |
main(java.lang.String[] args)
Runs the Compiler.
|
void |
run()
Runs the Compiler and calls System.exit() with the exit status of the
compiler.
|
protected void |
setRunOptions(CompilerOptions options)
Sets options based on the configurations set flags API.
|
boolean |
shouldRunCompiler() |
protected CommandLineRunner(java.lang.String[] args)
protected CommandLineRunner(java.lang.String[] args, java.io.PrintStream out, java.io.PrintStream err)
protected CompilerOptions createOptions()
run()
is called.
createCompiler() is called before createOptions(), so getCompiler()
will not return null when createOptions() is called.protected Compiler createCompiler()
run()
is
called.protected java.util.List<SourceFile> createExterns() throws AbstractCommandLineRunner.FlagUsageException, java.io.IOException
AbstractCommandLineRunner.FlagUsageException
java.io.IOException
public static java.util.List<SourceFile> getDefaultExterns() throws java.io.IOException
java.io.IOException
public boolean shouldRunCompiler()
public static void main(java.lang.String[] args)
protected boolean isInTestMode()
protected com.google.javascript.jscomp.AbstractCommandLineRunner.CommandLineConfig getCommandLineConfig()
protected DiagnosticGroups getDiagnosticGroups()
protected void setRunOptions(CompilerOptions options) throws AbstractCommandLineRunner.FlagUsageException, java.io.IOException
AbstractCommandLineRunner.FlagUsageException
java.io.IOException
protected final A getCompiler()
public final void run()
protected java.io.PrintStream getErrorPrintStream()
protected java.util.List<SourceFile> createInputs(java.util.List<java.lang.String> files, boolean allowStdIn) throws AbstractCommandLineRunner.FlagUsageException, java.io.IOException
files
- A list of filenamesallowStdIn
- Whether '-' is allowed appear as a filename to represent
stdin. If true, '-' is only allowed to appear once.AbstractCommandLineRunner.FlagUsageException
java.io.IOException
protected void checkModuleName(java.lang.String name) throws AbstractCommandLineRunner.FlagUsageException
name
- The module nameAbstractCommandLineRunner.FlagUsageException
- if the validation failsprotected int doRun() throws AbstractCommandLineRunner.FlagUsageException, java.io.IOException
AbstractCommandLineRunner.FlagUsageException
java.io.IOException
protected java.io.OutputStream filenameToOutputStream(java.lang.String fileName) throws java.io.IOException
java.io.IOException