Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forced-out and forcer-err to force the system console to use the output / error stream (fixes #856) #884

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion terminal/src/main/java/org/jline/terminal/TerminalBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public final class TerminalBuilder {
public static final String PROP_OUTPUT_ERR = "err";
public static final String PROP_OUTPUT_OUT_ERR = "out-err";
public static final String PROP_OUTPUT_ERR_OUT = "err-out";
public static final String PROP_OUTPUT_FORCED_OUT = "forced-out";
public static final String PROP_OUTPUT_FORCED_ERR = "forced-err";

//
// Other system properties controlling various jline parts
Expand Down Expand Up @@ -106,7 +108,9 @@ public enum SystemOutput {
SysOut,
SysErr,
SysOutOrSysErr,
SysErrOrSysOut
SysErrOrSysOut,
ForcedSysOut,
ForcedSysErr
}

/**
Expand Down Expand Up @@ -560,6 +564,12 @@ public SystemOutput computeSystemOutput() {
case PROP_OUTPUT_ERR_OUT:
systemOutput = SystemOutput.SysErrOrSysOut;
break;
case PROP_OUTPUT_FORCED_OUT:
systemOutput = SystemOutput.ForcedSysOut;
break;
case PROP_OUTPUT_FORCED_ERR:
systemOutput = SystemOutput.ForcedSysErr;
break;
default:
Log.debug("Unsupported value for " + PROP_OUTPUT + ": " + str + ". Supported values are: "
+ String.join(
Expand Down Expand Up @@ -672,6 +682,10 @@ private SystemStream select(Map<SystemStream, Boolean> system, SystemOutput syst
return select(system, SystemStream.Output, SystemStream.Error);
case SysErrOrSysOut:
return select(system, SystemStream.Error, SystemStream.Output);
case ForcedSysOut:
return SystemStream.Output;
case ForcedSysErr:
return SystemStream.Error;
}
return null;
}
Expand Down
Loading