add help command

This commit is contained in:
Able 2021-11-06 22:31:21 -05:00
parent 806ea59664
commit 69bdfc2601

View file

@ -7,10 +7,8 @@ use std::{
const VERSION: &str = env!("CARGO_PKG_VERSION"); const VERSION: &str = env!("CARGO_PKG_VERSION");
fn main() { fn main() {
loop { loop {
// use the `>` character as the prompt
// need to explicitly flush this to ensure it prints before read_line
print!("~> "); print!("~> ");
// need to explicitly flush this to ensure it prints before read_line
stdout().flush().unwrap(); stdout().flush().unwrap();
let mut input = String::new(); let mut input = String::new();
@ -39,6 +37,7 @@ fn main() {
previous_command = None; previous_command = None;
} }
"version" => println!("Rash version: {}", VERSION), "version" => println!("Rash version: {}", VERSION),
"help" => println!("Able Shell help utility"),
"exit" => return, "exit" => return,
command => { command => {
let stdin = previous_command.map_or(Stdio::inherit(), |output: Child| { let stdin = previous_command.map_or(Stdio::inherit(), |output: Child| {