Class SubshellCommand
java.lang.Object
org.dellroad.jct.core.simple.AbstractSimpleCommand
org.dellroad.jct.core.simple.command.SubshellCommand
- All Implemented Interfaces:
SimpleCommand
- Direct Known Subclasses:
JShellCommand
A command that fires up subshell sessions.
This command only works within shell sessions.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSubshellCommand(Shell shell, String usage, String summary, String detail) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected ShellRequestbuildShellRequest(ShellSession session, String name, List<String> params) Create the subshell request.protected ShellSessioncreateSubshell(ShellRequest request) Create the subshell session.intexecute(ConsoleSession<?, ?> session0, String name, List<String> params) Execute this command in the current thread and return success or failure.protected intexecuteSubshell(ShellSession session) Execute the subshell session.Methods inherited from class org.dellroad.jct.core.simple.AbstractSimpleCommand
getHelpDetail, getHelpSummary, getUsage, printUsage
-
Field Details
-
shell
-
-
Constructor Details
-
SubshellCommand
Constructor.- Parameters:
shell- the subshell, which creates the underlying subshell sessionsusage- usage string, or null if command takes no argumentssummary- help summarydetail- help detail- Throws:
IllegalArgumentException- ifshell,summaryordetailis null
-
-
Method Details
-
execute
public int execute(ConsoleSession<?, ?> session0, String name, List<String> params) throws InterruptedExceptionDescription copied from interface:SimpleCommandExecute this command in the current thread and return success or failure.In the failure case, some error information should be written to standard error.
- Parameters:
session0- associated sessionname- the name under which this command was invokedparams- zero or more command arguments (does not include command name)- Returns:
- zero if successful, non-zero error code if an error occurred
- Throws:
InterruptedException- if execution is interrupted
-
executeSubshell
Execute the subshell session.The implementation in
SubshellCommandsimply invokesConsoleSession.execute().- Parameters:
session- subshell session- Returns:
- subshell exit value
- Throws:
InterruptedException- if execution is interrupted viaConsoleSession.interrupt()IllegalArgumentException- ifsessionis null
-
createSubshell
Create the subshell session.- Parameters:
request- subshell session request- Returns:
- subshell session
- Throws:
IOException- if an I/O error occursIllegalArgumentException- ifrequestis null
-
buildShellRequest
Create the subshell request.- Parameters:
session- outer shell sessionname- command nameparams- command parameters- Returns:
- new shell request
-