public abstract class CommonCommands extends Object implements Commands
Created by Jeff Gaynor
on 10/30/13 at 4:14 PM
Modifier and Type | Field and Description |
---|---|
static String |
BATCH_FILE_LINE_CONTINUES
If a line ends with this (after the comment is removed), then glow it on to the
next input line.
|
static String |
BATCH_FILE_MODE_FLAG |
static String |
BATCH_MODE_FLAG |
protected boolean |
batchFile |
protected String |
CL_INPUT_FILE_FLAG |
protected String |
CL_OUTPUT_FILE_FLAG |
protected String |
defaultIndent |
static String |
INDENT |
protected MyLoggingFacade |
logger |
String |
placeHolder
This is used wherever a missing value is.
|
Modifier | Constructor and Description |
---|---|
protected |
CommonCommands(MyLoggingFacade logger) |
Modifier and Type | Method and Description |
---|---|
void |
clear_env(InputLine inputLine) |
protected void |
clearEnvHelp() |
void |
debug(String x)
Write a debug message to the log.
|
void |
echo(InputLine inputLine) |
protected void |
echoHelp() |
void |
error(String x)
Write an error message to the log.
|
BufferedReader |
getBufferedReader() |
CLIDriver |
getDriver() |
protected String |
getInput(String prompt,
String defaultValue)
Creates the input prompt and shows the supplied default value.
|
String |
getPlaceHolder()
Gets the placeholder for missing values.
|
protected String |
getValue(String x)
Returns the value if it is not empty of a placeholder if it is.
|
protected boolean |
gracefulExit(boolean exitNow,
String msg)
Exit gracefully.
|
void |
info(String x)
Write an informational message to the log
|
protected boolean |
isBatch()
returns true if this is either a batch file or in batch mode.
|
boolean |
isBatchFile() |
boolean |
isBatchMode()
If this is invoked from the command line with the batch mode flag, then this should process
commands strictly without user intervention, failing if, for instance, some parameters are missing
rather than prompting for them.
|
boolean |
isDebugOn()
Query if debugging is enabled for this logger.
|
protected boolean |
isEmpty(String x) |
protected boolean |
isOk(String x) |
boolean |
isPrintOuput()
If this is set true, then no output is generated.
|
boolean |
isVerbose() |
protected void |
logit(String x) |
void |
print_env(InputLine inputLine) |
protected void |
printEnvHelp() |
protected void |
printReadEnvHelp() |
protected void |
printSaveEnvHelp() |
protected void |
printSetEnvHelp() |
void |
read_env(InputLine inputline) |
protected String |
readFile(String filename)
read a text file and return a single string of the content.
|
protected net.sf.json.JSONObject |
readJSON(String filename) |
protected String |
readline() |
void |
save_env(InputLine inputLine) |
protected void |
say(String x)
Prints with the default indent and a linefeed.
|
protected void |
say2(String x)
Output the string without any linefeed.
|
protected void |
sayi(String x)
prints with the current indent and a linefeed.
|
protected void |
sayi2(String x)
Output a line without a linefeed and using the indent currently in force.
|
protected void |
sayv(String x)
Use this for verbose mode.
|
void |
set_env(InputLine inputline) |
void |
set_output_on(InputLine inputLine) |
void |
set_verbose_on(InputLine inputLine)
So batch files can change whether or not they are verbose
|
void |
setBatchFile(boolean batchFile) |
void |
setBatchMode(boolean batchMode) |
void |
setBufferedReader(BufferedReader bufferedReader) |
void |
setDebugOn(boolean setOn)
Enable/disable debugging for this logger
|
void |
setDriver(CLIDriver driver) |
protected void |
setOuputOnHelp() |
void |
setPlaceHolder(String placeHolder) |
void |
setPrintOuput(boolean printOuput) |
void |
setVerbose(boolean verbose) |
protected void |
setVerboseHelp() |
protected boolean |
showHelp(InputLine inputLine)
returns "true if the command has the flag --help in it.
|
void |
version(InputLine inputLine) |
protected void |
versionHelp() |
void |
warn(String x)
Write a warning to the log.
|
public static String BATCH_MODE_FLAG
protected MyLoggingFacade logger
protected String defaultIndent
public static final String INDENT
public String placeHolder
protected String CL_OUTPUT_FILE_FLAG
protected String CL_INPUT_FILE_FLAG
public static String BATCH_FILE_MODE_FLAG
public static String BATCH_FILE_LINE_CONTINUES
ls \//My comment -la \ foobaris the same as entering the single line
ls -la foobarNotice that the lines are concatenated and the comment is stripped out.
protected boolean batchFile
protected CommonCommands(MyLoggingFacade logger)
public boolean isBatchMode()
CLIDriver
instance sets this at the time of
invocation.public void setBatchMode(boolean batchMode)
public void debug(String x)
Logable
public void error(String x)
Logable
public void info(String x)
Logable
public boolean isDebugOn()
Logable
public void setDebugOn(boolean setOn)
Logable
setDebugOn
in interface Logable
public void warn(String x)
Logable
public BufferedReader getBufferedReader()
public void setBufferedReader(BufferedReader bufferedReader)
protected String readline()
protected void say(String x)
x
- protected void sayi(String x)
x
- protected void say2(String x)
x
- protected void sayi2(String x)
readline()
.x
- protected boolean showHelp(InputLine inputLine)
inputLine
- protected boolean isOk(String x)
protected String getInput(String prompt, String defaultValue)
prompt
- defaultValue
- protected boolean isEmpty(String x)
public String getPlaceHolder()
public void setPlaceHolder(String placeHolder)
protected String getValue(String x)
x
- public CLIDriver getDriver()
public void setDriver(CLIDriver driver)
protected void printReadEnvHelp()
protected void printSetEnvHelp()
protected void printSaveEnvHelp()
protected void printEnvHelp()
protected void clearEnvHelp()
protected boolean gracefulExit(boolean exitNow, String msg)
exitNow
- msg
- public boolean isBatchFile()
public void setBatchFile(boolean batchFile)
protected boolean isBatch()
protected void sayv(String x)
x
- protected void logit(String x)
public boolean isVerbose()
protected void setVerboseHelp()
public void set_verbose_on(InputLine inputLine) throws Exception
inputLine
- Exception
public void setVerbose(boolean verbose)
public boolean isPrintOuput()
public void setPrintOuput(boolean printOuput)
protected void setOuputOnHelp()
protected void versionHelp()
public void version(InputLine inputLine)
protected void echoHelp()
public void echo(InputLine inputLine)
protected String readFile(String filename) throws Exception
filename
- Exception
Copyright © 2019. All Rights Reserved.