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 ShellRequest
buildShellRequest
(ShellSession session, String name, List<String> params) Create the subshell request.protected ShellSession
createSubshell
(ShellRequest request) Create the subshell session.int
execute
(ConsoleSession<?, ?> session0, String name, List<String> params) Execute this command in the current thread and return success or failure.protected int
executeSubshell
(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
,summary
ordetail
is null
-
-
Method Details
-
execute
public int execute(ConsoleSession<?, ?> session0, String name, List<String> params) throws InterruptedExceptionDescription copied from interface:SimpleCommand
Execute 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
SubshellCommand
simply invokesConsoleSession.execute()
.- Parameters:
session
- subshell session- Returns:
- subshell exit value
- Throws:
InterruptedException
- if execution is interrupted viaConsoleSession.interrupt()
IllegalArgumentException
- ifsession
is null
-
createSubshell
Create the subshell session.- Parameters:
request
- subshell session request- Returns:
- subshell session
- Throws:
IOException
- if an I/O error occursIllegalArgumentException
- ifrequest
is null
-
buildShellRequest
Create the subshell request.- Parameters:
session
- outer shell sessionname
- command nameparams
- command parameters- Returns:
- new shell request
-