Package org.kissweb

Class CL

java.lang.Object
org.kissweb.CL

public class CL extends Object
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
  • Field Details

  • Constructor Details

    • CL

      public CL()
  • Method Details

    • EHN

      public static int EHN(String s)
      Evaluate entered response.

      This utility routine evaluates a string, returning one of the following values:

      • NOTHING if the string is null or empty
      • HELP if the string is "help" (ignoring case)
      • END if the string is "end" (ignoring case)
      • VALUE otherwise
      Parameters:
      s - the string to be evaluated
      Returns:
      one of NOTHING, HELP, END, or VALUE
    • inputCharacter

      public static String inputCharacter(String choices, String prompt)
      Prompt user for a character input.
      Parameters:
      choices - a string of all valid single character responses
      prompt -
      Returns:
      the single character that was entered
    • inputString

      public static String inputString(int min, int max, String prompt)
      Prompt user for a string input.

      The string is valid if its length is between the min and max arguments (inclusive).

      Parameters:
      min - the minimum number of characters
      max - the maximum number of characters
      prompt - the prompt to be displayed
      Returns:
      the entered string
    • inputNumber

      public static String inputNumber(double min, double max, int decimalPlaces, String prompt)
      Prompt user for a numeric input.

      The numeric value is valid if it is between the min and max arguments (inclusive) and has the correct number of decimal places.

      Parameters:
      min - the minimum number
      max - the maximum number
      decimalPlaces - the number of decimal places
      prompt - the prompt to be displayed
      Returns:
      the entered string
    • inputList

      public static String inputList(String options, String prompt)
      Prompt user for a string input among a list of choices.
      Parameters:
      options - a comma-separated string of all valid responses
      prompt -
      Returns:
      the selected string
    • inputDate

      public static String inputDate(int min, int max, String prompt)
      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 format
      max - maximum acceptable date in the YYYYMMDD format
      prompt -
      Returns:
      EHN string or date as a string in the YYYYMMDD format
    • error

      public static void error(String msg)
      Display an error message and abort any command string processing.
      Parameters:
      msg - the error message to display.
    • println

      public static void println(String s)
      Print a line of output terminating with a new line.
      Parameters:
      s -