chore: run clippy and cargo fmt on pending changes

This commit is contained in:
Chance 2025-04-07 23:06:48 -04:00
parent 6efaf7a291
commit bb9bca8ca5
Signed by: caznix
GPG key ID: 489D213143D753FD
8 changed files with 34 additions and 25 deletions

View file

@ -1,9 +1,9 @@
use std::{
borrow::Cow::{self, Borrowed, Owned},
sync::Arc,
time::{SystemTime, UNIX_EPOCH},
};
use chrono::Local;
use colored::Colorize;
use parking_lot::Mutex;
use rustyline::{
@ -11,6 +11,7 @@ use rustyline::{
Hinter, KeyEvent, RepeatCount, Validator, completion::Completer, error::ReadlineError,
highlight::Highlighter, hint::HistoryHinter, history::DefaultHistory,
};
#[allow(unused_imports)]
use tracing::{debug, error, info, warn};
use super::handler::COMMAND_MANAGER;
@ -178,6 +179,24 @@ pub fn evaluate_command(input: &str) -> Result<()> {
Ok(())
}
fn format_time() -> String {
let now = SystemTime::now();
let duration = now.duration_since(UNIX_EPOCH).unwrap();
let total_seconds = duration.as_secs();
let nanos = duration.subsec_nanos();
let milliseconds = nanos / 1_000_000;
let seconds_since_midnight_utc = total_seconds % (24 * 3600);
let hour = (seconds_since_midnight_utc / 3600) % 24;
let minute = (seconds_since_midnight_utc / 60) % 60;
let second = seconds_since_midnight_utc % 60;
format!(
"{:02}:{:02}:{:02}.{:03}",
hour, minute, second, milliseconds
)
}
pub async fn handle_repl() -> Result<()> {
let mut rl = Editor::<MyHelper, DefaultHistory>::new()?;
rl.set_helper(Some(MyHelper {
@ -197,7 +216,7 @@ pub async fn handle_repl() -> Result<()> {
}
loop {
let time = Local::now().format("%H:%M:%S.%3f").to_string();
let time = format_time();
let prompt = format!("[{}/{}] {}", time, "SHELL", ">>\t");
let sig = rl.readline(&prompt.bright_white());