java.lang.Object
com.aoapps.hodgepodge.util.ShellInterpreter
- All Implemented Interfaces:
Runnable
AOSH is a Bourne-shell-like command interpreter
to control the AOServ Client utilities.- Author:
- AO Industries, Inc.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA optional parser buffer to aid performance of repeated parsing.static classThe result of a parsing pass. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final TerminalWriterprotected final Readerprotected final TerminalWriterprotected String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedShellInterpreter(Reader in, TerminalWriter out, TerminalWriter err) protectedShellInterpreter(Reader in, TerminalWriter out, TerminalWriter err, String[] rawArgs, String... args) protectedShellInterpreter(Reader in, Writer out, Writer err) protected -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckRawArgsVersusArgs(String[] rawArgs, String... args) Performs checks and assertions that rawArgs is consistent with args.final voidClears the screen.protected abstract StringgetName()final longgetPid()final longgetPID()Deprecated.protected abstract Stringprotected abstract booleanhandleCommand(String[] rawArgs, String... args) Processes one command and returns.protected final booleanisAlive()protected final booleanfinal voidprotected abstract ShellInterpreternewShellInterpreter(Reader in, TerminalWriter out, TerminalWriter err, String[] rawArgs, String... args) static ShellInterpreter.ParseResultParses a stream of characters into arguments.static ShellInterpreter.ParseResultparse(Reader in, Writer promptOut, ShellInterpreter.ParseBuffer buffer) Parses a stream of characters into arguments.final voidrun()If arguments were provided, executes that command.
-
Field Details
-
in
-
out
-
err
-
status
-
-
Constructor Details
-
ShellInterpreter
-
ShellInterpreter
protected ShellInterpreter(Reader in, TerminalWriter out, TerminalWriter err, String[] rawArgs, String... args) -
ShellInterpreter
-
ShellInterpreter
-
-
Method Details
-
checkRawArgsVersusArgs
public static void checkRawArgsVersusArgs(String[] rawArgs, String... args) throws IllegalArgumentException, AssertionError Performs checks and assertions that rawArgs is consistent with args. -
clear
Clears the screen.- Throws:
IOException
-
getName
-
getPid
public final long getPid() -
getPID
Deprecated.Please usegetPid()instead. -
getPrompt
- Throws:
IOExceptionSQLException
-
handleCommand
protected abstract boolean handleCommand(String[] rawArgs, String... args) throws IOException, SQLException Processes one command and returns.- Parameters:
rawArgs- The raw args contain the same content asargs, but quoting is left intact. Will benullwhen the arguments were split outside, such as being from the arguments passed to the Java application main method.args- The args with all shell quoting decoded.- Throws:
IOExceptionSQLException
-
isAlive
protected final boolean isAlive() -
isInteractive
protected final boolean isInteractive() -
jobs
-
newShellInterpreter
protected abstract ShellInterpreter newShellInterpreter(Reader in, TerminalWriter out, TerminalWriter err, String[] rawArgs, String... args) -
run
public final void run()If arguments were provided, executes that command. Otherwise, reads frominuntil end of file orexit. -
parse
public static ShellInterpreter.ParseResult parse(Reader in, Writer promptOut, ShellInterpreter.ParseBuffer buffer) throws IOException Parses a stream of characters into arguments. Reads up to the firstnewlinethat is not backslash-escaped, or until end of file.- Parameters:
in- the reader to parsepromptOut- the optional output to write promptsbuffer- the optional buffer, may benull- Throws:
IOException
-
parse
Parses a stream of characters into arguments. Reads up to the firstnewlinethat is not backslash-escaped, or until end of file.- Parameters:
in- the reader to parsepromptOut- the optional output to write prompts- Throws:
IOException
-

getPid()instead.