RustyTerm 0.1.3

RustyTerm is an advanced terminal fully build in Rust.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::io::{self, Write};
use std::process::{exit, Command};
use std::{env, path};

pub fn text_editor(args: Vec<&str>, command: &str) {
    if args.len() < 2 {
        eprintln!("{}: missing filename", command);
    } else {
        let editor = env::var("EDITOR").unwrap_or_else(|_| command.to_string());
        let filename = args[1];
        let output = Command::new(&editor).arg(&filename).status().unwrap();
        if !output.success() {
            eprintln!("{}: command failed", command);
        }
    }
}