From 83dad1f4d692a5e1970d0df1ba688682f8bd2547 Mon Sep 17 00:00:00 2001 From: fdai7374 Date: Sat, 28 Jan 2023 18:50:34 +0100 Subject: [PATCH] feat: add help command --- src/builtins/help.rs | 27 +++++++++++++++++++++++++++ src/builtins/mod.rs | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 src/builtins/help.rs diff --git a/src/builtins/help.rs b/src/builtins/help.rs new file mode 100644 index 0000000..d78b5d5 --- /dev/null +++ b/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) -> 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(()) + } +} \ No newline at end of file diff --git a/src/builtins/mod.rs b/src/builtins/mod.rs index 96913eb..51ccbe6 100644 --- a/src/builtins/mod.rs +++ b/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)>> = Lazy::new(|| { ("pwd", Box::new(pwd::Pwd)), ("segfault", Box::new(segfault::Segfault)), ("sus", Box::new(sus::Sus)), + ("help", Box::new(help::Help)), ] });