From 8d1f838a6836924c2bb8ab83f7ca4466b9982a17 Mon Sep 17 00:00:00 2001 From: Caznix Date: Fri, 6 Dec 2024 16:55:49 -0500 Subject: [PATCH] fix formatting --- engine/src/core/repl/commands.rs | 22 +++++++++++++--------- engine/src/core/repl/mod.rs | 14 ++++---------- engine/src/core/repl/repl.rs | 6 ++---- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/engine/src/core/repl/commands.rs b/engine/src/core/repl/commands.rs index e9b756d..cf59b48 100644 --- a/engine/src/core/repl/commands.rs +++ b/engine/src/core/repl/commands.rs @@ -1,14 +1,12 @@ use std::{ffi::OsStr, process::Command}; - -use parking_lot::Mutex; use lazy_static::lazy_static; - - -use crate::core::repl::repl::evaluate_command; +use parking_lot::Mutex; use super::COMMAND_LIST; -const MAX_RECURSION_DEPTH: usize = 500; // increasing this value WILL cause a stack overflow. attempt at your own risk - Caz +use crate::core::repl::repl::evaluate_command; +const MAX_RECURSION_DEPTH: usize = 500; // increasing this value WILL cause a stack overflow. attempt at your own risk - + // Caz lazy_static! { static ref RECURSION_DEPTH: Mutex = parking_lot::Mutex::new(0); @@ -59,11 +57,17 @@ pub(crate) fn exec(args: Vec) -> anyhow::Result<()> { println!("File path: {:#?}", file_path); if !file_path.is_file() { - eprintln!("Error: File does not exist or is not a valid file: {}", file_path.display()); - return Ok(()); + eprintln!( + "Error: File does not exist or is not a valid file: {}", + file_path.display() + ); + return Ok(()); } if file_path.extension() != Some(OsStr::new("zensh")) { - eprintln!("Error: File is not a zenshell script: {:#?}", file_path.extension()); + eprintln!( + "Error: File is not a zenshell script: {:#?}", + file_path.extension() + ); //TODO: dont panic on this error return Ok(()); } diff --git a/engine/src/core/repl/mod.rs b/engine/src/core/repl/mod.rs index 0f84cfd..ebafd40 100644 --- a/engine/src/core/repl/mod.rs +++ b/engine/src/core/repl/mod.rs @@ -3,7 +3,7 @@ pub mod repl; use std::{borrow::Borrow, collections::HashMap, sync::Arc}; -use anyhow::Ok; +use anyhow::Context; use colored::Colorize; use lazy_static::lazy_static; use log::{debug, info}; @@ -42,11 +42,7 @@ impl Command { } Callable::WithArgs(f) => match args { Some(args) => f(args), - None => { - Ok(()) - - - }, + None => Ok(()), }, } } @@ -140,7 +136,7 @@ impl CommandList { .aliases .read() .get_key_value(&name) - .unwrap() + .context("Failed to get alias")? .1 .to_string(); @@ -176,9 +172,7 @@ impl CommandList { eprintln!("Did you mean: '{}'?", similar.green().italic().bold()); Ok(()) } - None => { - Ok(()) - } + None => Ok(()), } } } diff --git a/engine/src/core/repl/repl.rs b/engine/src/core/repl/repl.rs index 5ef467d..eae0dc9 100644 --- a/engine/src/core/repl/repl.rs +++ b/engine/src/core/repl/repl.rs @@ -3,8 +3,6 @@ use std::{ sync::Arc, }; - - use chrono::Local; use colored::Colorize; use log::debug; @@ -111,7 +109,7 @@ fn register_commands() { "exec", Some("Executes a .nyx file."), Callable::WithArgs(commands::exec), - Some(1), + Some(1), ); // Example of adding aliases for commands @@ -172,7 +170,7 @@ pub fn evaluate_command(input: &str) -> anyhow::Result<()> { cmd_name.to_string(), if args.is_empty() { None } else { Some(args) }, )?; - }; + } Ok(()) }