Class EdtShell
java.lang.Object
com.e1c.g5.v8.dt.internal.cli.api.EdtShell
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
edtsh
(org.apache.felix.service.command.CommandSession session) static String
extractCommand
(String[] args) Extracts EDT CLI command from the given command line aguments, if possible.extractFile
(String[] args) Extracts EDT CLI script file and its arguments from the given command line aguments, if possible.static String
prepareCommand
(String[] args, org.apache.felix.service.command.CommandSession session) Prepares EDT command(s) for execution from the given CLI arguments, if possible.static int
Runs shell.static void
setupEdtSession
(org.apache.felix.service.command.CommandSession session, org.apache.felix.service.command.CommandSession parent) Sets up some important session parameters, such as the default command scope, command prompt and working directory.
-
Field Details
-
COMMAND_ARG
- See Also:
-
FILE_ARG
- See Also:
-
OK_CODE
public static final int OK_CODE- See Also:
-
GENERAL_ERROR_CODE
public static final int GENERAL_ERROR_CODE- See Also:
-
FILE_NOT_FOUND_CODE
public static final int FILE_NOT_FOUND_CODE- See Also:
-
WORKSPACE_IN_USE_CODE
public static final int WORKSPACE_IN_USE_CODE- See Also:
-
INTERRUPTED_CODE
public static final int INTERRUPTED_CODE- See Also:
-
EXCEPTION_CODE
public static final int EXCEPTION_CODE- See Also:
-
HARD_EXIT_CODE
public static final int HARD_EXIT_CODE- See Also:
-
-
Constructor Details
-
EdtShell
public EdtShell()
-
-
Method Details
-
extractCommand
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
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 benull
- 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
Runs shell.- Parameters:
session
- session to run command in, cannotnull
.command
- command to run. May benull
, 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 benull
.parent
- parent session to copy variables from, may benull
.- Throws:
IOException
- if unable to get the current working directory.
-
edtsh
public void edtsh(org.apache.felix.service.command.CommandSession session)
-