diff --git a/src/builtins/mod.rs b/src/builtins/mod.rs index 13a0966..3fdb60b 100644 --- a/src/builtins/mod.rs +++ b/src/builtins/mod.rs @@ -14,6 +14,7 @@ mod pwd; mod quote; mod segfault; mod sus; +mod time; pub struct BuiltinConfig { pub prompt_style: PromptStyle, @@ -45,6 +46,8 @@ const BUILTINS: Lazy)>> = Lazy::new(|| { ("quote", Box::new(quote::Quote)), ("segfault", Box::new(segfault::Segfault)), ("sus", Box::new(sus::Sus)), + ("quote", Box::new(quote::Quote)), + ("time", Box::new(time::Time)), ] }); diff --git a/src/builtins/time.rs b/src/builtins/time.rs new file mode 100644 index 0000000..e1623cb --- /dev/null +++ b/src/builtins/time.rs @@ -0,0 +1,15 @@ +use chrono::{DateTime, Local, TimeZone}; + +use crate::error::ShellError; + +use super::{Builtin, BuiltinConfig}; + +pub struct Time; + +impl Builtin for Time { + fn execute(&mut self, _: &mut BuiltinConfig, _: Vec) -> Result<(), ShellError> { + let time = Local::now(); + println!("{time}"); + Ok(()) + } +}