Interface CommandSession
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
CommandSessionImpl
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classReturn the current session. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclassLoader(ClassLoader classLoader) voidclose()Close this command session.Convert an object to another type.voidcurrentDir(Path path) execute(CharSequence commandline) Execute a program in this session.Get the current foreground job or null.Convert an object to string form (CharSequence).Get the value of a variable.Return the PrintStream for the console.Return the input stream that is the first of the pipeline.jobs()List jobs.Set the value of a variable.voidsetJobListener(JobListener listener) Set the job listener for this session.
-
Field Details
-
OPTION_NO_GLOB
- See Also:
-
-
Method Details
-
currentDir
Path currentDir() -
currentDir
-
classLoader
ClassLoader classLoader() -
classLoader
-
execute
Execute a program in this session.- Parameters:
commandline- the commandline- Returns:
- the result of the execution
- Throws:
Exception- on exception
-
close
void close()Close this command session. After the session is closed, it will throw IllegalStateException when it is used.- Specified by:
closein interfaceAutoCloseable
-
getKeyboard
InputStream getKeyboard()Return the input stream that is the first of the pipeline. This stream is sometimes necessary to communicate directly to the end user. For example, a "less" or "more" command needs direct input from the keyboard to control the paging.- Returns:
- InpuStream used closest to the user or null if input is from a file.
-
getConsole
PrintStream getConsole()Return the PrintStream for the console. This must always be the stream "closest" to the user. This stream can be used to post messages that bypass the piping. If the output is piped to a file, then the object returned must be null.- Returns:
- PrintStream the console print stream
-
get
-
put
-
format
Convert an object to string form (CharSequence). The level is defined in the Converter interface, it can be one of INSPECT, LINE, PART. This function always returns a non null value. As a last resort, toString is called on the Object.- Parameters:
target- the targetlevel- the level- Returns:
- CharSequence
-
convert
-
jobs
-
foregroundJob
-
setJobListener
Set the job listener for this session.- Parameters:
listener- the listener
-