Class EdtShell

java.lang.Object
com.e1c.g5.v8.dt.internal.cli.api.EdtShell
All Implemented Interfaces:
ICliCommand

public class EdtShell extends Object implements ICliCommand
Provides the edtsh command, which is an extended command line shell. The original GoGo shell has some limitations, e.g. it does not support UTF-8 input, and its error reporting is limited. This shell fixes this issues and may add other needed capabilities.

Also, this shell provides support for -command and -file command line arguments.

Note! This is a special command provider, which is registered directly. It must not be registered via the com.e1c.g5.v8.dt.cli.api.cliCommand extension point.

  • Field Details

  • Constructor Details

    • EdtShell

      public EdtShell()
  • Method Details

    • extractCommand

      public static String extractCommand(String[] args)
      Extracts EDT CLI command from the given command line aguments, if possible.
      Parameters:
      args - command line arguments.
      Returns:
      CLI command, or null, if the command is not provided.
      Throws:
      IllegalArgumentException - if CLI usage error found.
    • extractFile

      public static Pair<Path,List<String>> extractFile(String[] args)
      Extracts EDT CLI script file and its arguments from the given command line aguments, if possible.
      Parameters:
      args - command line arguments.
      Returns:
      CLI script file with script arguments, or null, if the file is not provided.
      Throws:
      IllegalArgumentException - if CLI usage error found.
    • prepareCommand

      public static String prepareCommand(String[] args, org.apache.felix.service.command.CommandSession session) throws IOException
      Prepares EDT command(s) for execution from the given CLI arguments, if possible.
      Parameters:
      args - command line arguments.
      session - CLI session, cannot be null
      Returns:
      EDT command(s), or null, if the neither file nor command are not provided.
      Throws:
      IOException - CLI script file is provided, but can't be read.
    • runShell

      public static int runShell(org.apache.felix.service.command.CommandSession session, String command)
      Runs shell.
      Parameters:
      session - session to run command in, cannot null.
      command - command to run. May be null, in which case interactive shell is started.
      Returns:
      return code of the given command or the result of the last command user executed in the shell (if possible to convert to int).
    • setupEdtSession

      public static void setupEdtSession(org.apache.felix.service.command.CommandSession session, org.apache.felix.service.command.CommandSession parent) throws IOException
      Sets up some important session parameters, such as the default command scope, command prompt and working directory.
      Parameters:
      session - session to set up, cannot be null.
      parent - parent session to copy variables from, may be null.
      Throws:
      IOException - if unable to get the current working directory.
    • edtsh

      public void edtsh(org.apache.felix.service.command.CommandSession session)