From c73c43596b840e78cea1afee263a8fc8f6aa1334 Mon Sep 17 00:00:00 2001 From: fdai7375 Date: Thu, 2 Feb 2023 19:33:37 +0100 Subject: [PATCH] feat: add time command --- src/builtins/mod.rs | 3 +++ src/builtins/time.rs | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/builtins/time.rs 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(()) + } +}