Package berlin.yuna.clu.logic
Class Terminal
java.lang.Object
berlin.yuna.clu.logic.Terminal
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbreakOnError(boolean breakOnError) Will throwIllegalStateExceptionon error when trueClears the console outputconsoleInfo()consoleError()final TerminalconsumerErrorStream(Consumer<String>... consumerError) final TerminalconsumerInfoStream(Consumer<String>... consumerInfo) static TerminalClean copy of terminal with default consumer and clean console logdir()Executes a command with (sh or cmd.exe) ant he help of theProcessBuilderDefault working directory: user.dirtimeoutMs(long)if timeout is neededExecutes a command with (sh or cmd.exe) ant he help of theProcessBuilderDefault working directory: user.dirtimeoutMs(long)if timeout is neededintprocess()Executes a command with (sh or cmd.exe) with the help of theProcessBuilderbooleanrunning()intstatus()longtimeoutMs(long timeoutMs) Alternative toProcess.waitFor()as sometimes a process can be to fast or to slow forProcess.waitFor()or you need a timeout Its combined with (breakOnError(boolean)) Default : -1 (deactivated) Also activates a heartbeat check (timeoutMs / 40) which will also timeout if there is no output is happeningtoString()longwaitFor()waitFor(long waitForMs)
-
Constructor Details
-
Terminal
public Terminal()
-
-
Method Details
-
copyOf
Clean copy of terminal with default consumer and clean console log- Parameters:
terminal- terminal to copy- Returns:
- new terminal copy
-
clearConsole
Clears the console outputconsoleInfo()consoleError()- Returns:
- Terminal
-
consumerInfoStream
- Parameters:
consumerInfo- consumer for console info stream- Returns:
- Terminal
-
consumerErrorStream
- Parameters:
consumerError- consumer for console error stream- Returns:
- Terminal
-
timeoutMs
public long timeoutMs()- Returns:
- timeout in milliseconds
- See Also:
-
timeoutMs
Alternative toProcess.waitFor()as sometimes a process can be to fast or to slow forProcess.waitFor()or you need a timeout Its combined with (breakOnError(boolean)) Default : -1 (deactivated) Also activates a heartbeat check (timeoutMs / 40) which will also timeout if there is no output is happening- Parameters:
timeoutMs- timeout in milliseconds- Returns:
- Terminal
-
breakOnError
public boolean breakOnError()- Returns:
- boolean of current state
- See Also:
-
breakOnError
Will throwIllegalStateExceptionon error when true- Parameters:
breakOnError- set state- Returns:
- Terminal
-
dir
- Returns:
- current working directory
- See Also:
-
waitFor
public long waitFor()- Returns:
- wait time after command exited
- See Also:
-
waitFor
- Returns:
- set ms to wait after execution if the command is faster than logging its messages (default=5)
- See Also:
-
dir
- Parameters:
dir- sets the working directory- Returns:
- Terminal
-
dir
- Parameters:
dir- sets the working directory- Returns:
- Terminal
-
dir
- Parameters:
dir- sets the working directory- Returns:
- Terminal
-
process
- Returns:
- the currently used
Process- return null when no command was executed
-
consoleInfo
- Returns:
- returns the console output
-
consoleInfoList
- Returns:
- returns the console output as list
-
consoleError
- Returns:
- returns the console error output
-
consoleErrorList
- Returns:
- returns the console error as list
-
execute
Executes a command with (sh or cmd.exe) ant he help of theProcessBuilderDefault working directory: user.dirtimeoutMs(long)if timeout is needed- Parameters:
command- command to execute- Returns:
- a new
Processobject for managing the sub process
-
execute
Executes a command with (sh or cmd.exe) ant he help of theProcessBuilderDefault working directory: user.dirtimeoutMs(long)if timeout is needed- Parameters:
command- command to executewaitForMs- overwrites defaultwaitFor(long)for this call - null = async- Returns:
- a new
Processobject for managing the sub process
-
process
Executes a command with (sh or cmd.exe) with the help of theProcessBuilder- Parameters:
command- command to execute- Returns:
- a new
Processobject for managing the sub process - Throws:
IOException- if an I/O error occurs
-
status
public int status()- Returns:
- status code from last command
Process.waitFor()
-
running
public boolean running()- Returns:
- returns true if process is still running
-
messageCount
public int messageCount() -
toString
-