public abstract class CommandLineApplication extends Application
Constructor and Description |
---|
CommandLineApplication(toools.io.file.RegularFile launcher) |
Modifier and Type | Method and Description |
---|---|
void |
addOption(java.lang.String longName,
java.lang.String shortName,
java.lang.String regex,
java.lang.String defaultValue,
java.lang.String description) |
protected void |
cancelLastPrint() |
static java.lang.String |
computeFileName(java.lang.String appName,
java.lang.Class<? extends CommandLineApplication> c) |
void |
createLauncher() |
protected abstract void |
declareArguments(java.util.Collection<ArgumentSpecification> argumentSpecifications) |
protected abstract void |
declareOptions(java.util.Collection<OptionSpecification> optionSpecifications) |
void |
ensureMandatoryStuffAreSpecified(CommandLine cmdLine) |
protected toools.config.Configuration |
extractConfiguration() |
toools.io.file.RegularFile |
findFile(java.lang.String name) |
toools.io.file.RegularFile |
getActualConfigurationFile() |
CommandLineSpecification |
getCommandLineSpecification() |
toools.io.file.Directory |
getDataDirectory() |
protected toools.io.file.RegularFile |
getDataFile(java.lang.String filename) |
toools.io.file.RegularFile |
getDefaultConfigurationFile() |
java.lang.String |
getHelp(boolean printUtilityOptions) |
toools.io.file.Directory |
getHomeDirectory() |
toools.io.file.Directory |
getInstallationDirectory() |
toools.io.file.Directory |
getJarsDirectory() |
java.lang.String |
getLastPrint() |
java.lang.String |
getLauncherCode() |
java.lang.String |
getName()
Computes the name of the script out of the name of the class For example,
"lucci.cmdline.MyScript" becomes "MyScript".
|
protected java.lang.String |
getOptionValue(CommandLine cmdLine,
java.lang.String optionName) |
java.lang.String |
getUsage() |
toools.io.file.RegularFile |
getUserConfigurationFile() |
toools.io.file.RegularFile |
getUserFile(java.lang.String filename) |
double |
getVerbosity() |
protected java.lang.String |
getVMOptionsAsText() |
boolean |
isInteractive() |
protected boolean |
isOptionSpecified(CommandLine cmdLine,
java.lang.String optionName) |
protected void |
printDebugMessage(java.lang.Object... msg) |
protected void |
printExceptionStrackTrace(java.lang.Exception e) |
protected void |
printFatalError(java.lang.Object... msg) |
protected void |
printMessage(java.lang.Object... msg) |
protected void |
printMessage(java.io.PrintStream os,
java.lang.Object msg) |
protected void |
printMessage(java.io.PrintStream os,
java.lang.Object msg,
double importance,
boolean addnewline) |
protected void |
printMessageWithNoNewLine(java.lang.Object msg) |
protected void |
printNonFatalError(java.lang.Object... msg) |
protected void |
printWarning(java.lang.Object... msg) |
protected java.lang.String |
readUserInput(java.lang.String invitation,
java.lang.String regexp) |
int |
run(java.util.List<java.lang.String> args) |
int |
run(java.lang.String... args) |
abstract int |
runScript(CommandLine cmdLine) |
void |
saveConfiguration(java.lang.String key,
java.lang.String value) |
int |
select(java.util.List<java.lang.String> list) |
void |
setInteractive(boolean interactive) |
void |
setVerbosity(double verbosity) |
getApplicationName, getAuthor, getClasspathEntry, getLicence, getShortDescription, getVersion, getVMOptions, getYear
public CommandLineApplication(toools.io.file.RegularFile launcher)
public toools.io.file.Directory getInstallationDirectory()
public void addOption(java.lang.String longName, java.lang.String shortName, java.lang.String regex, java.lang.String defaultValue, java.lang.String description)
public final java.lang.String getUsage()
protected final boolean isOptionSpecified(CommandLine cmdLine, java.lang.String optionName)
protected final java.lang.String getOptionValue(CommandLine cmdLine, java.lang.String optionName)
public final java.lang.String getName()
public static java.lang.String computeFileName(java.lang.String appName, java.lang.Class<? extends CommandLineApplication> c)
public final java.lang.String getHelp(boolean printUtilityOptions)
public final int run(java.lang.String... args) throws java.lang.Throwable
java.lang.Throwable
public final int run(java.util.List<java.lang.String> args) throws java.lang.Throwable
java.lang.Throwable
protected abstract void declareOptions(java.util.Collection<OptionSpecification> optionSpecifications)
protected abstract void declareArguments(java.util.Collection<ArgumentSpecification> argumentSpecifications)
public final toools.io.file.Directory getJarsDirectory()
public final void createLauncher() throws java.io.IOException
java.io.IOException
public java.lang.String getLauncherCode()
protected final java.lang.String getVMOptionsAsText()
public abstract int runScript(CommandLine cmdLine) throws java.lang.Throwable
java.lang.Throwable
public CommandLineSpecification getCommandLineSpecification()
public final void ensureMandatoryStuffAreSpecified(CommandLine cmdLine) throws InvalidOptionValueException
InvalidOptionValueException
protected void printMessage(java.io.PrintStream os, java.lang.Object msg, double importance, boolean addnewline)
protected void cancelLastPrint()
protected final void printMessageWithNoNewLine(java.lang.Object msg)
protected final void printMessage(java.io.PrintStream os, java.lang.Object msg)
protected final void printMessage(java.lang.Object... msg)
protected final void printWarning(java.lang.Object... msg)
protected final void printDebugMessage(java.lang.Object... msg)
protected final void printNonFatalError(java.lang.Object... msg)
protected final void printFatalError(java.lang.Object... msg)
protected final void printExceptionStrackTrace(java.lang.Exception e)
protected final java.lang.String readUserInput(java.lang.String invitation, java.lang.String regexp)
public final double getVerbosity()
public final void setVerbosity(double verbosity)
public final toools.io.file.Directory getHomeDirectory()
public final int select(java.util.List<java.lang.String> list)
public final toools.io.file.Directory getDataDirectory()
public final toools.io.file.RegularFile getDefaultConfigurationFile()
public final toools.io.file.RegularFile getUserConfigurationFile()
public toools.io.file.RegularFile getUserFile(java.lang.String filename)
public final toools.io.file.RegularFile getActualConfigurationFile()
public toools.io.file.RegularFile findFile(java.lang.String name)
public java.lang.String getLastPrint()
protected toools.config.Configuration extractConfiguration() throws java.io.IOException
java.io.IOException
public void saveConfiguration(java.lang.String key, java.lang.String value) throws java.io.IOException
java.io.IOException
public boolean isInteractive()
public void setInteractive(boolean interactive)
protected toools.io.file.RegularFile getDataFile(java.lang.String filename)