Browse Source

feat: add help command

main
fdai7374 2 years ago
parent
commit
83dad1f4d6
  1. 27
      src/builtins/help.rs
  2. 2
      src/builtins/mod.rs

27
src/builtins/help.rs

@ -0,0 +1,27 @@
use crate::error::ShellError;
use crate::builtins::{Builtin, BuiltinConfig};
pub struct Help;
impl Builtin for Help {
fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> {
let commands =
"cd changes current working directory
change-prompt changes prompt style (default, bashlike, simpledirectory)
exit exits the shell
fetch prints out system information
help displays this command
ls lists contents of directory
open shows content of files
pwd shows path to current working directory
segfault exit but through segfault
sus shows amogus";
for line in commands.lines(){
println!("{}",line.trim_start());
}
Ok(())
}
}

2
src/builtins/mod.rs

@ -6,6 +6,7 @@ mod cd;
mod change_prompt;
mod exit;
mod fetch;
mod help;
mod ls;
mod open;
mod pwd;
@ -39,6 +40,7 @@ const BUILTINS: Lazy<Vec<(&str, Box<dyn Builtin>)>> = Lazy::new(|| {
("pwd", Box::new(pwd::Pwd)),
("segfault", Box::new(segfault::Segfault)),
("sus", Box::new(sus::Sus)),
("help", Box::new(help::Help)),
]
});

Loading…
Cancel
Save