Alternate constructor that tries all known readline implementations, in this order:
Alternate constructor that tries all known readline implementations, in this order:
- GNU Readline - Editline - Getline - JLine - Simple (pure Java)
application name
Alternate constructor taking a single readline implementation.
Alternate constructor taking a single readline implementation. Fails if that readline implementation cannot be found.
application name
readline implementation
the application name, used by some readline libraries for key-binding
list of readline libraries to try to load, in
order. The ReadlineType values are
defined by the grizzled.readline package.
delimiters to use when tokenizing a line for tab-completion.
o != arg0 is the same as !(o == (arg0)).
o != arg0 is the same as !(o == (arg0)).
the object to compare against this object for dis-equality.
false if the receiver object is equivalent to the argument; true otherwise.
o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).
o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).
the object to compare against this object for equality.
true if the receiver object is equivalent to the argument; false otherwise.
o == arg0 is the same as o.equals(arg0).
o == arg0 is the same as o.equals(arg0).
the object to compare against this object for equality.
true if the receiver object is equivalent to the argument; false otherwise.
Default list of readline libraries to try, in order.
Default list of readline libraries to try, in order.
Assumed output width of the screen.
Assumed output width of the screen.
StartCommandIdentifier is the list of characters that are
permitted as the first character of a white space-delimited,
multicharacter command name.
StartCommandIdentifier is the list of characters that are
permitted as the first character of a white space-delimited,
multicharacter command name. All other characters are assumed to
introduce single-character commands. Subclasses may override this value
to permit additional, or different, starting characters for
multicharacter command names. See the splitCommandAndArgs()method for more details.
Get all handlers.
Get all handlers. By default, this property combines thehandlers value with the default help handler,HelpHandler. If you define your own help handler, you'll
have to override the helpHandler property to return your
help handler, instead of the default one.
the application name, used by some readline libraries for key-binding
the application name, used by some readline libraries for key-binding
This method is used to cast the receiver object to be of type T0.
This method is used to cast the receiver object to be of type T0.
Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expressionList(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as
part of compilation it is not possible to check whether the contents of the list are of the requested typed.
the receiver object.
This method creates and returns a copy of the receiver object.
This method creates and returns a copy of the receiver object.
The default implementation of the clone method is platform dependent.
a copy of the receiver object.
This method is used to test whether the argument (arg0) is a reference to the
receiver object (this).
This method is used to test whether the argument (arg0) is a reference to the
receiver object (this).
The eq method implements an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation] on
non-null instances of AnyRef:
* It is reflexive: for any non-null instance x of type AnyRef, x.eq(x) returns true.
* It is symmetric: for any non-null instances x and y of type AnyRef, x.eq(y) returns true if and
only if y.eq(x) returns true.
* It is transitive: for any non-null instances x, y, and z of type AnyRef if x.eq(y) returns true and y.eq(z) returns true, then x.eq(z) returns true.
Additionally, the eq method has three other properties.
* It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of
x.eq(y) consistently returns true or consistently returns false.
* For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.
* null.eq(null) returns true.
When overriding the equals or hashCode methods, it is important to ensure that their behavior is
consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they
should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).
the object to compare against this object for reference equality.
true if the argument is a reference to the receiver object; false otherwise.
This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.
This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.
The default implementations of this method is an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence
relation]:
* It is reflexive: for any instance x of type Any, x.equals(x) should return true.
* It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and
only if y.equals(x) returns true.
* It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and
y.equals(z) returns true, then x.equals(z) should return true.
If you override this method, you should verify that your implementation remains an equivalence relation.
Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects
that are "equal" (o1.equals(o2) returns true) hash to the same
scala.Int
(o1.hashCode.equals(o2.hashCode)).
the object to compare against this object for equality.
true if the receiver object is equivalent to the argument; false otherwise.
Emit an error message in a consistent way.
Emit an error message in a consistent way. May be overridden by subclasses. The default implementation prints errors in red.
the message to emit
This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.
This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.
The details of when and if the finalize method are invoked, as well as the interaction between finalizeand non-local returns and exceptions, are all platform dependent.
Returns a representation that corresponds to the dynamic class of the receiver object.
Returns a representation that corresponds to the dynamic class of the receiver object.
The nature of the representation is platform dependent.
a representation that corresponds to the dynamic class of the receiver object.
Handles a command line, just as if it had been typed directly at the prompt.
Handles a command line, just as if it had been typed directly at the prompt.
the command line
KeepGoing to tell the main loop to continue,
or Stop to tell the main loop to be done.
Called when an end-of-file condition is encountered while reading a command (On Unix-like systems, with some readline libraries, this happens when the user pressed Ctrl-D).
Called when an end-of-file condition is encountered while reading a
command (On Unix-like systems, with some readline libraries, this
happens when the user pressed Ctrl-D). prompt. The default version
of this method simply returns Stop, causing the command
loop to exit.
KeepGoing to tell the main loop to continue,
or Stop to tell the main loop to be done.
Called when an empty command line is entered in response to the prompt.
Called when an empty command line is entered in response to the
prompt. The default version of this method simply returnsKeepGoing.
KeepGoing to tell the main loop to continue,
or Stop to tell the main loop to be done.
Called when an exception occurs during the main loop.
Called when an exception occurs during the main loop. This method
can handle the exception however it wants; it must return eitherKeepGoing or Stop. The default version
of this method dumps the exception stack trace and returnsStop.
the exception
KeepGoing to tell the main loop to continue,
or Stop to tell the main loop to be done.
Called when a command is entered that isn't recognized.
Called when a command is entered that isn't recognized. The default
version of this method prints an error message and returnsKeepGoing.
the command name
the command arguments
KeepGoing to tell the main loop to continue,
or Stop to tell the main loop to be done.
List of handlers.
List of handlers. The subclass must define this value to contain a
list of its handlers. The allHandlers property will combine
this list with the help handler to get the list of all handlers.
If you define your own help handler, you'll have to override thehelpHandler property to return your help handler, instead of
the default one.
Returns a hash code value for the object.
Returns a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet
not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0.
However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have
identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure
to verify that the behavior is consistent with the equals method.
the hash code value for the object.
Get the help handler.
Get the help handler. Override this property if you want to supply your own help handler.
Get the history object being used to record command history.
Get the history object being used to record command history.
the grizzled.readline.History object
This method is used to test whether the dynamic type of the receiver object is T0.
This method is used to test whether the dynamic type of the receiver object is T0.
Note that the test result of the test is modulo Scala's erasure semantics. Therefore the expression1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will
return true. In the latter example, because the type argument is erased as part of compilation it is not
possible to check whether the contents of the list are of the requested typed.
true if the receiver object is an instance of erasure of type T0; false otherwise.
Repeatedly issue a prompt, accept input, parse an initial prefix from the received input, and dispatch to execution handlers.
Repeatedly issue a prompt, accept input, parse an initial prefix from the received input, and dispatch to execution handlers.
o.ne(arg0) is the same as !(o.eq(arg0)).
o.ne(arg0) is the same as !(o.eq(arg0)).
the object to compare against this object for reference dis-equality.
false if the argument is not a reference to the receiver object; true otherwise.
Wakes up a single thread that is waiting on the receiver object's monitor.
Wakes up a single thread that is waiting on the receiver object's monitor.
Wakes up all threads that are waiting on the receiver object's monitor.
Wakes up all threads that are waiting on the receiver object's monitor.
Called after a command line is interpreted.
Called after a command line is interpreted. The default implementation
simply returns KeepGoing.
the command that invoked this handler
the remainder of the unparsed command line
KeepGoing to tell the main loop to continue,
or Stop to tell the main loop to be done.
Called immediately after the main loop (mainLoop()) ends
its command loop, this hook method can be used for cleanup.
Called immediately after the main loop (mainLoop()) ends
its command loop, this hook method can be used for cleanup. The
default implementation does nothing.
Called just before a command line is interpreted, this hook method can edit the command.
Called just before a command line is interpreted, this hook method can edit the command.
the command line
The possibly edited command, Some("") to signal an empty command, or None to signal EOF.
Called just before the main loop (mainLoop()) begins its
command loop, this hook method can be used for initialization.
Called just before the main loop (mainLoop()) begins its
command loop, this hook method can be used for initialization. The
default implementation does nothing.
The primary prompt string.
The primary prompt string.
Push a reader on the reader stack.
Push a reader on the reader stack. The reader on top of the stack
is used until it returns None (indicating EOF). Then, it is
removed from the stack, and the next reader is used. When the only
reader remaining on the stack returns None, the command
interpreter signals an EOF condition to the subclass (by callinghandleEOF()).
The reader is a simple function that takes a prompt string (which
it can choose to ignore) and returns a line of input
(Some(input)) or None for EOF. The line of input,
if returned, should not have a trailing newline.
the reader function
The second prompt string, used when additional input is being retrieved.
The second prompt string, used when additional input is being retrieved.
Split a command from its argument list, returning the command as one string and the remaining unparsed argument string as the other string.
Split a command from its argument list, returning the command as one string and the remaining unparsed argument string as the other string. The commmand name is parsed from the remaining arguments using the following rules:
- If the first non-white character if the input line is in the
StartCommandIdentifier string, then the command is assumed to be
a identifier that is separated from the arguments by white space.
- If the first character if the input line is not in the
StartCommandIdentifier string, then the command is assumed to be
a single-character command, with the arguments immediately
following the single character.
The StartCommandIdentifier string is an overridable field
defined by this class, consisting of the characters permitted to start
a multicharacter command. By default, it consists of alphanumerics.
Subclasses may override it to permit additional, or different, starting
characters for multicharacter commands.
For example, using the default identifier characters, this function will break the following commands into command + arguments as shown:
Input: foo bar bazResult: Command foo, argument string "bar baz"
Input: !barResult: Command ! argument string "bar"
Input: ? one twoResult: Command ? argument string "one two"
Subclasses may override this method to parse commands differently.
the input type
A (commandName, argumentString) 2-tuple
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
a string representation of the object.
delimiters to use when tokenizing a line for tab-completion.
delimiters to use when tokenizing a line for tab-completion.
Emit a warning message in a consistent way.
Emit a warning message in a consistent way. May be overridden by subclasses. The default implementation prints the message with the prefix "Warning: ".
the message to emit
Base class for command interpreters.
CommandInterpreteris the base class of any command interpreter. This class and theCommandHandlertrait provide a simple framework for writing line-oriented command-interpreters. This framework is conceptually similar to the Pythoncmdmodule and itsCmdclass, though the implementation differs substantially in places.For reading input from the console,
CommandInterpreterwill use of any of the readline libraries supported by thegrizzled.readlinepackage. All of those libraries support a persistent command history, and most support command completion and command editing.A command line consists of an initial command name, followed by a list of arguments to that command. The
CommandInterpreterclass's command reader automatically separates the command and the remaining arguments, via thesplitCommandAndArgs()method. Parsing the arguments is left to the actual command implementation. The rules for how the command is split from the remainder of the input line are outlined in the documentation for thesplitCommandAndArgs()method.