Package org.kissweb
Class CL
java.lang.Object
org.kissweb.CL
Command Line IO.
In the old days, programs worked by asking one question at a time. Although this is very primitive in today's terms, it did work. You could build any application with no GUI and just this interface. The advantage is that it is very fast to put together a program that works sufficiently well. This may make sense for internal use situations.
Author: Blake McBride
Date: 1/4/22
In the old days, programs worked by asking one question at a time. Although this is very primitive in today's terms, it did work. You could build any application with no GUI and just this interface. The advantage is that it is very fast to put together a program that works sufficiently well. This may make sense for internal use situations.
Author: Blake McBride
Date: 1/4/22
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Evaluate entered response.static void
Display an error message and abort any command string processing.static String
inputCharacter
(String choices, String prompt) Prompt user for a character input.static String
Prompt user for a date input.static String
Prompt user for a string input among a list of choices.static String
inputNumber
(double min, double max, int decimalPlaces, String prompt) Prompt user for a numeric input.static String
inputString
(int min, int max, String prompt) Prompt user for a string input.static void
Print a line of output terminating with a new line.
-
Field Details
-
NEXT
public static final int NEXT- See Also:
-
PREVIOUS
public static final int PREVIOUS- See Also:
-
END
public static final int END- See Also:
-
HELP
public static final int HELP- See Also:
-
NOTHING
public static final int NOTHING- See Also:
-
VALUE
public static final int VALUE- See Also:
-
-
Constructor Details
-
CL
public CL()
-
-
Method Details
-
EHN
Evaluate entered response.This utility routine evaluates a string, returning one of the following values:
-
inputCharacter
Prompt user for a character input.- Parameters:
choices
- a string of all valid single character responsesprompt
-- Returns:
- the single character that was entered
-
inputString
Prompt user for a string input.The string is valid if its length is between the
min
andmax
arguments (inclusive).- Parameters:
min
- the minimum number of charactersmax
- the maximum number of charactersprompt
- the prompt to be displayed- Returns:
- the entered string
-
inputNumber
Prompt user for a numeric input.The numeric value is valid if it is between the
min
andmax
arguments (inclusive) and has the correct number of decimal places.- Parameters:
min
- the minimum numbermax
- the maximum numberdecimalPlaces
- the number of decimal placesprompt
- the prompt to be displayed- Returns:
- the entered string
-
inputList
Prompt user for a string input among a list of choices.- Parameters:
options
- a comma-separated string of all valid responsesprompt
-- Returns:
- the selected string
-
inputDate
Prompt user for a date input. Also accepted are "today", "yesterday", and "tomorrow". The date is expected to be in the MM/DD/YYYY or other common formats. The date is valid if it is between the given min and max values.- Parameters:
min
- minimum acceptable date int the YYYYMMDD formatmax
- maximum acceptable date in the YYYYMMDD formatprompt
-- Returns:
- EHN string or date as a string in the YYYYMMDD format
-
error
Display an error message and abort any command string processing.- Parameters:
msg
- the error message to display.
-
println
Print a line of output terminating with a new line.- Parameters:
s
-
-