Package net.hydromatic.morel
Class Shell
- java.lang.Object
-
- net.hydromatic.morel.Shell
-
public class Shell extends Object
Command shell for ML, powered by JLine3.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceShell.ConfigShell configuration.private static classShell.ConfigImplImplementation ofShell.Config.(package private) static interfaceShell.LineFnAbstraction of a terminal's line reader.(package private) static classShell.LineTypeType of line fromShell.LineFn.(package private) static classShell.ReaderLineFnImplementation ofShell.LineFnthat reads from a reader.(package private) static classShell.SubShellSimplified 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 classShell.TerminalLineFnImplementation ofShell.LineFnthat reads from JLine's terminal.
-
Field Summary
Fields Modifier and Type Field Description private Shell.ConfigImplconfigprivate org.jline.terminal.Terminalterminal
-
Constructor Summary
Constructors Constructor Description Shell(Shell.Config config, org.jline.terminal.Terminal terminal)Creates a Shell.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private 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 voidhelp(Consumer<String> outLines)private static <T> Tinstantiate(String className, Class<T> clazz)Instantiates a class.static voidmain(String[] args)Command-line entry point.static Shell.Configparse(Shell.Config config, List<String> argList)Parses an argument list to an equivalent Config.protected voidpause()Pauses after creating the terminal.voidrun()(package private) static voidusage(Consumer<String> outLines)
-
-
-
Field Detail
-
config
private final Shell.ConfigImpl config
-
terminal
private final org.jline.terminal.Terminal terminal
-
-
Constructor Detail
-
Shell
public Shell(Shell.Config config, org.jline.terminal.Terminal terminal)
Creates a Shell.
-
-
Method Detail
-
main
public static void main(String[] args)
Command-line entry point.- Parameters:
args- Command-line arguments
-
create
public static Shell create(List<String> args, InputStream in, OutputStream out) throws IOException
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
public static Shell.Config parse(Shell.Config config, List<String> argList)
Parses an argument list to an equivalent Config.
-
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
private static boolean canIgnoreLine(StringBuilder buf, String line)
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
private String banner()
Generates a banner to be shown on startup.
-
run
public void run()
-
-