Sharkysoft home

lava.io
Class ConsoleCommandShell

java.lang.Object
  |
  +--lava.io.ConsoleCommandShell

public class ConsoleCommandShell
extends java.lang.Object

Console-based command interface.

Details: A ConsoleCommandShell interacts with the user by issuing prompts and parsing the user's responses. When instructed, this class writes a prompt to the console, waits for the user to type a line of text, and then begins parsing the line. Each line is divided into substrings, which are returned one at a time during subsequent method calls. By convention, the first substring is called the "command," while all additional substrings on the same line are called "parameters."

The algorithm used by this class to parse input lines is similar to the algorithms used in common command-line shells, such as in a Unix or MS-DOS shell. For example:

*This feature will be implemented in a future release.

This class depends heavily on the ConsoleDialog class, particularly on ConsoleDialog.query_words. It is worthwhile to consult the documentation for that class in order to better understand the behavior of this class.

Version:
1999.05.04
Author:
Sharky

Field Summary
 java.lang.String prompt
          Prompt sent to the user to indicate that a line of text (i.e., a command) is requested.
 
Constructor Summary
ConsoleCommandShell(ConsoleDialog console, java.lang.String prompt)
          Initializes a new ConsoleCommandShell with the specified prompt.
 
Method Summary
 java.lang.String getCommand()
          Outputs the command prompt to the console, waits for a response, parses it, and then returns the command (i.e., the first word of the response).
 java.lang.String getParam()
          Returns the next parameter from the most recently parsed command line.
 int paramsRemaining()
          Returns the number of parameters that remain to be read.
 void writeln(java.lang.String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prompt

public java.lang.String prompt
Prompt sent to the user to indicate that a line of text (i.e., a command) is requested.
Constructor Detail

ConsoleCommandShell

public ConsoleCommandShell(ConsoleDialog console,
                           java.lang.String prompt)
Initializes a new ConsoleCommandShell with the specified prompt.
Parameters:
the - prompt
Method Detail

getCommand

public java.lang.String getCommand()
                            throws java.io.IOException
Outputs the command prompt to the console, waits for a response, parses it, and then returns the command (i.e., the first word of the response).
Returns:
the command, or null if a blank line was entered
Throws:
java.io.IOException - if an I/O error occurs

getParam

public java.lang.String getParam()
                          throws java.io.IOException
Returns the next parameter from the most recently parsed command line. This method should not be called before get_command.
Returns:
the next parameter, or null if there are no more words on the current line
Throws:
java.io.IOException - if an I/O error occurs

paramsRemaining

public int paramsRemaining()
Returns the number of parameters that remain to be read.
Returns:
number of parameters remaining to be read

writeln

public void writeln(java.lang.String s)
             throws java.io.IOException

Sharkysoft home