Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Caznix committed Dec 6, 2024
1 parent 4d2383d commit 8d1f838
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
22 changes: 13 additions & 9 deletions engine/src/core/repl/commands.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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());
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(());
}
Expand Down
14 changes: 4 additions & 10 deletions engine/src/core/repl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -42,11 +42,7 @@ impl Command {
}
Callable::WithArgs(f) => match args {
Some(args) => f(args),
None => {
Ok(())


},
None => Ok(()),
},
}
}
Expand Down Expand Up @@ -140,7 +136,7 @@ impl CommandList {
.aliases
.read()
.get_key_value(&name)
.unwrap()
.context("Failed to get alias")?
.1
.to_string();

Expand Down Expand Up @@ -176,9 +172,7 @@ impl CommandList {
eprintln!("Did you mean: '{}'?", similar.green().italic().bold());
Ok(())
}
None => {
Ok(())
}
None => Ok(()),
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions engine/src/core/repl/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use std::{
sync::Arc,
};



use chrono::Local;
use colored::Colorize;
use log::debug;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(())
}

Expand Down

0 comments on commit 8d1f838

Please sign in to comment.