Class Shell

java.lang.Object
net.hydromatic.morel.Shell

public class Shell extends Object
Command shell for ML, powered by JLine3.
  • Field Details

    • config

      private final Shell.ConfigImpl config
    • terminal

      private final org.jline.terminal.Terminal terminal
  • Constructor Details

    • Shell

      public Shell(Shell.Config config, org.jline.terminal.Terminal terminal)
      Creates a Shell.
  • Method Details

    • 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.
    • usage

      static void usage(Consumer<String> outLines)
    • help

      static void help(Consumer<String> outLines)
    • 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()
    • instantiate

      @Nonnull private static <T> T instantiate(String className, Class<T> clazz)
      Instantiates a class.

      Assumes that the class has a public no-arguments constructor.