diff --git a/src/builtins/mod.rs b/src/builtins/mod.rs index f063ceb..b48b346 100644 --- a/src/builtins/mod.rs +++ b/src/builtins/mod.rs @@ -13,6 +13,7 @@ mod pwd; mod quote; mod segfault; mod sus; +mod time; pub struct BuiltinConfig { pub prompt_style: PromptStyle, @@ -43,6 +44,7 @@ const BUILTINS: Lazy)>> = Lazy::new(|| { ("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(()) + } +}