infrarust_server_manager 1.6.3

A Minecraft server manager that handles API monitoring and system commands
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::io::Error as IoError;
use std::process::Command;

pub fn execute_command(command: &str) -> Result<String, IoError> {
    let output = Command::new("powershell")
        .arg("-Command")
        .arg(command)
        .output()?;

    if output.status.success() {
        let result = String::from_utf8_lossy(&output.stdout).trim().to_string();
        Ok(result)
    } else {
        let error = String::from_utf8_lossy(&output.stderr).to_string();
        Err(IoError::new(std::io::ErrorKind::Other, error))
    }
}