working terminal

This commit is contained in:
Penwing 2024-01-16 12:53:03 +01:00
parent 1b9d5dcd95
commit 1eb22767d7

View file

@ -4,6 +4,7 @@
use eframe::egui; use eframe::egui;
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;
use std::process::Command;
const TERMINAL_HEIGHT : f32 = 200.0; const TERMINAL_HEIGHT : f32 = 200.0;
@ -26,7 +27,13 @@ fn main() -> Result<(), eframe::Error> {
} }
fn run_command(cmd : String) -> String { fn run_command(cmd : String) -> String {
cmd let command = "> ".to_owned() + &cmd.clone() + "\n";
let output = Command::new("sh")
.arg("-c")
.arg(cmd)
.output()
.expect("failed to execute process");
(command + &String::from_utf8_lossy(&output.stdout)).to_string()
} }
@ -38,6 +45,7 @@ struct MyApp {
command_history: String, command_history: String,
} }
impl Default for MyApp { impl Default for MyApp {
fn default() -> Self { fn default() -> Self {
Self { Self {