fix formatting

This commit is contained in:
Chance 2024-12-06 16:55:49 -05:00 committed by BitSyndicate
parent c163860c0a
commit ae62990e90
3 changed files with 19 additions and 23 deletions

View file

@ -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<usize> = parking_lot::Mutex::new(0);
@ -59,11 +57,17 @@ pub(crate) fn exec(args: Vec<String>) -> 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());
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(());
}

View file

@ -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(()),
}
}
}

View file

@ -3,8 +3,6 @@ use std::{
sync::Arc,
};
use chrono::Local;
use colored::Colorize;
use log::debug;
@ -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(())
}