lazycrate/
commands.rs

1use crate::app::App;
2use crate::panel::PanelName;
3use std::process::{Command, Stdio};
4
5// TODO: later cleanup
6pub fn do_command(app: &mut App, cmd: &str) {
7    let mut out = Command::new("cargo")
8        .args(["clippy"])
9        .stdout(Stdio::piped())
10        .stderr(Stdio::piped())
11        .spawn()
12        .unwrap();
13
14    // .stdout;
15    // let mut reader = BufReader::new(out).lines();
16    // let status = out.wait();
17
18    // let reader = BufReader::new(out);
19    // let mut total_lines = vec![];
20    // for s in reader.lines() {
21    // total_lines.push(s.unwrap());
22    // }
23    let status = out.wait();
24    let code = status.unwrap().code().unwrap();
25    let fake_out: String;
26
27    if code == 0 {
28        fake_out = format!("Cmd: {} | Code: {}", cmd, code);
29    } else {
30        fake_out = format!("Cmd: {} | Code: {}", cmd, code);
31    }
32    app.get_specific(PanelName::Output).content = vec![fake_out];
33}