Package net.hydromatic.morel
Class Shell
java.lang.Object
net.hydromatic.morel.Shell
Command shell for ML, powered by JLine3.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceShell configuration.private static classImplementation ofShell.Config.(package private) static interfaceAbstraction of a terminal's line reader.(package private) static enumType of line fromShell.LineFn.(package private) static classImplementation ofShell.LineFnthat reads from a reader.(package private) static classSimplified shell that works in both interactive mode (where input and output is a terminal) and batch mode (where input is a file, and output is to an array of lines).private static classImplementation ofShell.LineFnthat reads from JLine's terminal. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Shell.ConfigImplprivate final org.jline.terminal.Terminal -
Constructor Summary
ConstructorsConstructorDescriptionShell(Shell.Config config, org.jline.terminal.Terminal terminal) Creates a Shell. -
Method Summary
Modifier and TypeMethodDescriptionprivate Stringbanner()Generates a banner to be shown on startup.private static booleancanIgnoreLine(StringBuilder buf, String line) Returns whether we can ignore a line.static Shellcreate(List<String> args, InputStream in, OutputStream out) Creates a Shell.static Shellcreate(Shell.Config config, InputStream in, OutputStream out) Creates a Shell.(package private) static voidprivate static <T> Tinstantiate(String className, Class<T> clazz) Instantiates a class.static voidCommand-line entry point.static Shell.Configparse(Shell.Config config, List<String> argList) Parses an argument list to an equivalent Config.protected final voidpause()Pauses after creating the terminal.voidrun()(package private) static void
-
Field Details
-
config
-
terminal
private final org.jline.terminal.Terminal terminal
-
-
Constructor Details
-
Shell
Creates a Shell.
-
-
Method Details
-
main
Command-line entry point.- Parameters:
args- Command-line arguments
-
create
Creates a Shell.- Throws:
IOException
-
create
public static Shell create(Shell.Config config, InputStream in, OutputStream out) throws IOException Creates a Shell.- Throws:
IOException
-
parse
Parses an argument list to an equivalent Config. -
usage
-
help
-
pause
protected final void pause()Pauses after creating the terminal.Calls the value set by
Shell.Config.withPauseFn(Runnable)which, for the default config, does nothing; the instance used in testing pauses for a few milliseconds, which gives classes time to load and makes test deterministic. -
canIgnoreLine
Returns whether we can ignore a line. We can ignore a line if it consists only of comments, spaces, and optionally semicolon, and if we are not on a continuation line. -
banner
Generates a banner to be shown on startup. -
run
public void run() -
instantiate
Instantiates a class.Assumes that the class has a public no-arguments constructor.
-