Browse Source

feat: add time command

main
fdai7375 2 years ago
committed by fdai7451
parent
commit
c73c43596b
  1. 3
      src/builtins/mod.rs
  2. 15
      src/builtins/time.rs

3
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<Vec<(&str, Box<dyn Builtin>)>> = 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)),
]
});

15
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<String>) -> Result<(), ShellError> {
let time = Local::now();
println!("{time}");
Ok(())
}
}
Loading…
Cancel
Save