Class BasicCliMain

java.lang.Object
io.permazen.cli.main.BasicCliMain
Direct Known Subclasses:
CliMain

public class BasicCliMain extends Object
A "main" class for Permazen CLI applications.
  • Field Details

    • showErrorStackTraces

      protected boolean showErrorStackTraces
      Determines whether full stack traces should be displayed when exceptions occur.
  • Constructor Details

    • BasicCliMain

      public BasicCliMain()
  • Method Details

    • getErrorPrefix

      public String getErrorPrefix()
      Get the prefix to use when displaying errors.

      The implementation in BasicCliMain returns "Error".

    • run

      public int run(String[] args)
      Execute the CLI application.
      Parameters:
      args - command line arguments
      Returns:
      application exit value (0 = success, non-zero = error)
    • buildCliConfig

      protected CliConfig buildCliConfig()
      Build a CliConfig to use.

      The implementation in BasicCliMain returns a new PermazenCliConfig. Subclasses can override this method to restrict to lower layers (e.g., Core API), add additional command-line flags, etc.

      Returns:
      CLI configuration
    • buildJShellCommand

      protected org.dellroad.jct.jshell.command.JShellCommand buildJShellCommand()
      Build a JShellCommand to use as the "jshell" command implementation.

      The implementation in BasicCliMain returns a new PermazenJShellCommand. Subclasses can override this method to add additional configuration, startup scripts, etc.

      Returns:
      "jshell" command, or null for the default
    • main

      public static void main(BasicCliMain main, String[] args)
      Main entry point for a CLI application using the given BasicCliMain instance.

      This method never returns; instead, it invokes System.exit(int) with an appropriate exit code.

      Parameters:
      main - CLI application
    • main

      public static void main(String[] args)
      Main entry point for a BasicCliMain CLI application.