public abstract class ConfigurableCommandsImpl extends Object implements Commands
Commands
implementations that do everything.
Created by Jeff Gaynor
on 5/20/13 at 11:35 AM
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_FILE_LONG_OPTION |
static String |
CONFIG_FILE_OPTION |
static String |
CONFIG_NAME_LONG_OPTION |
static String |
CONFIG_NAME_OPTION |
static String |
DEBUG_LONG_OPTION |
static String |
DEBUG_OPTION |
static String |
DEFAULT_LOG_FILE |
static String |
ENV_LONG_OPTION |
static String |
ENV_OPTION |
static String |
HELP_LONG_OPTION |
static String |
HELP_OPTION |
static String |
LOG_FILE_LONG_OPTION |
static String |
LOG_FILE_OPTION |
static String |
USE_COMPONENT_LONG_OPTION |
static String |
USE_COMPONENT_OPTION |
static String |
VERBOSE_LONG_OPTION |
static String |
VERBOSE_OPTION |
Modifier | Constructor and Description |
---|---|
protected |
ConfigurableCommandsImpl(MyLoggingFacade logger) |
Modifier and Type | Method and Description |
---|---|
void |
debug(String x)
Write a debug message to the log.
|
void |
error(String x)
Write an error message to the log.
|
org.apache.commons.cli.CommandLine |
getCommandLine() |
abstract String |
getComponentName()
For the configuration.
|
String |
getConfigFile() |
org.apache.commons.configuration.tree.ConfigurationNode |
getConfigurationNode() |
AbstractEnvironment |
getEnvironment() |
Map<Object,Object> |
getGlobalEnv() |
abstract ConfigurationLoader<? extends AbstractEnvironment> |
getLoader() |
String |
getLogfileName() |
MyLoggingFacade |
getMyLogger() |
protected org.apache.commons.cli.Options |
getOptions()
Override this to set up your options.
|
protected boolean |
getOptions(String[] args)
Returns true if execution should continue, false if not.
|
protected boolean |
hasOption(String shortForm,
String longForm)
Checks if the long or short form is part of the command line options.
|
void |
info(String x)
Write an informational message to the log
|
void |
initialize()
Called at initialization to read and process the command line arguments.
|
boolean |
isDebugOn()
Query if debugging is enabled for this logger.
|
boolean |
isVerbose() |
void |
load(InputLine inputLine) |
protected void |
loadConfig(String filename,
String configName) |
protected String |
padLineWithBlanks(String x,
int width)
This will take a String and append the correct number of blanks on the
left so it is the right width.
|
protected void |
parseCommandLine(String[] args) |
protected void |
readEnv(String path) |
protected void |
say(String x) |
void |
setConfigFile(String configFile) |
void |
setConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode configurationNode) |
void |
setDebugOn(boolean setOn)
Enable/disable debugging for this logger
|
void |
setEnvironment(AbstractEnvironment environment) |
void |
setLogfileName(String logfileName) |
void |
setMyLogger(MyLoggingFacade myLoggingFacade) |
void |
setVerbose(boolean verbose) |
protected boolean |
showHelp(InputLine inputLine)
returns "true if the command has the flag --help in it.
|
protected void |
showLoadHelp() |
boolean |
use(InputLine inputLine)
Override this to invoke the specific components that make up your CLI.
|
abstract void |
useHelp() |
void |
warn(String x)
Write a warning to the log.
|
public static final String VERBOSE_OPTION
public static final String VERBOSE_LONG_OPTION
public static final String DEBUG_OPTION
public static final String DEBUG_LONG_OPTION
public static final String LOG_FILE_OPTION
public static final String LOG_FILE_LONG_OPTION
public static final String HELP_OPTION
public static final String HELP_LONG_OPTION
public static final String CONFIG_FILE_OPTION
public static final String CONFIG_FILE_LONG_OPTION
public static final String USE_COMPONENT_OPTION
public static final String USE_COMPONENT_LONG_OPTION
public static final String DEFAULT_LOG_FILE
public static final String ENV_OPTION
public static final String ENV_LONG_OPTION
public static final String CONFIG_NAME_OPTION
public static final String CONFIG_NAME_LONG_OPTION
protected ConfigurableCommandsImpl(MyLoggingFacade logger)
protected boolean showHelp(InputLine inputLine)
inputLine
- protected void say(String x)
protected void showLoadHelp()
public AbstractEnvironment getEnvironment() throws Exception
Exception
public void setEnvironment(AbstractEnvironment environment)
public abstract String getComponentName()
public abstract ConfigurationLoader<? extends AbstractEnvironment> getLoader()
public org.apache.commons.configuration.tree.ConfigurationNode getConfigurationNode()
public void setConfigurationNode(org.apache.commons.configuration.tree.ConfigurationNode configurationNode)
protected void readEnv(String path)
public void initialize()
protected void loadConfig(String filename, String configName) throws Exception
Exception
public String getConfigFile()
public void setConfigFile(String configFile)
protected void parseCommandLine(String[] args) throws org.apache.commons.cli.UnrecognizedOptionException, org.apache.commons.cli.ParseException
org.apache.commons.cli.UnrecognizedOptionException
org.apache.commons.cli.ParseException
public org.apache.commons.cli.CommandLine getCommandLine()
protected boolean getOptions(String[] args) throws Exception
args
- Exception
public boolean isDebugOn()
Logable
public void setDebugOn(boolean setOn)
Logable
setDebugOn
in interface Logable
protected boolean hasOption(String shortForm, String longForm)
shortForm
- longForm
- protected org.apache.commons.cli.Options getOptions()
Options options = super.getOptions();
options.addOptions(SHORT_FORM, LONG_FORM, ... // This is in the commons documentation
checkAction(SHORT_FORM, LONG_FORM, ACTION_CODE);
public void setMyLogger(MyLoggingFacade myLoggingFacade)
public MyLoggingFacade getMyLogger()
public void debug(String x)
Logable
public void info(String x)
Logable
public void warn(String x)
Logable
public void error(String x)
Logable
public String getLogfileName()
public void setLogfileName(String logfileName)
public boolean isVerbose()
public void setVerbose(boolean verbose)
protected String padLineWithBlanks(String x, int width)
x
- width
- public abstract void useHelp()
Copyright © 2019. All Rights Reserved.