Skip to content

Commit ee54b4f

Browse files
committed
add env var altering such that we can make applications think they have
full color support, this makes them more willing on average to spit out ANSI Escape codes #checkpoint
1 parent 103bfe7 commit ee54b4f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/ControlledProgram.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,18 @@ pub struct ControlledProgramInstance {
107107
impl ControlledProgramInstance {
108108
pub fn new(name: &str, exe_path: &str, arguments: Vec<String>, working_dir: String) -> Self {
109109
let mut process = Command::new(exe_path);
110-
let mut process = process.stdin(Stdio::piped());
111-
process = process.stdout(Stdio::piped());
112-
process = process.current_dir(working_dir.clone());
110+
let mut process = process //this line needs to be here to prevent dropped value error
111+
.stdin(Stdio::piped()) //pipe stdin
112+
.stdout(Stdio::piped()) //pipe stdout
113+
.current_dir(working_dir.clone()) //set the working directory, makes the app think that its being run from within working_dir
114+
// Set environment variables to simulate a full terminal
115+
.env("TERM", "xterm-256color") // Standard terminal type with 256 colors
116+
.env("COLORTERM", "truecolor") // Indicate 24-bit color support
117+
.env("COLUMNS", "120") // Default terminal width
118+
.env("LINES", "30") // Default terminal height
119+
.env("TERM_PROGRAM", "RustServerController") // Terminal program name
120+
.env("FORCE_COLOR", "1"); // Force colored output in many applications
121+
113122
for arg in arguments.iter() {
114123
process = process.arg(arg.replace("\\\\", "\\").replace('\"', ""));
115124
}

0 commit comments

Comments
 (0)