finally fix workflow i hope
This commit is contained in:
parent
2974886ad2
commit
616e4b545d
8 changed files with 113 additions and 126 deletions
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "engine"
|
||||
name = "zenyx"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
repository = "https://github.com/Zenyx-Engine/Zenyx"
|
||||
|
@ -8,7 +8,6 @@ anyhow = "1.0.94"
|
|||
backtrace = "0.3.74"
|
||||
chrono = "0.4.39"
|
||||
colored = "2.2.0"
|
||||
crashreport = "1.0.1"
|
||||
dirs-next = "2.0.0"
|
||||
|
||||
lazy_static.workspace = true
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use std::{fs, path::PathBuf, str::FromStr};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use colored::Colorize;
|
||||
use mlua::prelude::*;
|
||||
use anyhow::anyhow;
|
||||
use mlua::{Lua, MultiValue};
|
||||
use parking_lot::RwLock;
|
||||
use regex::Regex;
|
||||
use rustyline::{error::ReadlineError, DefaultEditor};
|
||||
use rustyline::{DefaultEditor, error::ReadlineError};
|
||||
|
||||
use super::{handler::Command, input::tokenize};
|
||||
use crate::core::repl::handler::COMMAND_MANAGER;
|
||||
|
|
|
@ -140,7 +140,6 @@ impl CommandManager {
|
|||
.insert(command.get_name().to_lowercase(), command);
|
||||
}
|
||||
|
||||
|
||||
pub fn add_alias(&mut self, alias: &str, command: &str) {
|
||||
self.aliases.insert(
|
||||
alias.to_string().to_lowercase(),
|
||||
|
@ -149,7 +148,6 @@ impl CommandManager {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub trait Command: Send + Sync {
|
||||
fn execute(&self, args: Option<Vec<String>>) -> Result<(), anyhow::Error>;
|
||||
fn undo(&self);
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
use commands::{
|
||||
ClearCommand, CounterCommand, ExitCommand, HelpCommand, PanicCommmand,ExecFile
|
||||
};
|
||||
use commands::{ClearCommand, CounterCommand, ExecFile, ExitCommand, HelpCommand, PanicCommmand};
|
||||
|
||||
use crate::commands;
|
||||
|
||||
|
@ -13,7 +11,6 @@ pub fn setup() {
|
|||
commands!(
|
||||
HelpCommand,
|
||||
ExecFile,
|
||||
|
||||
ClearCommand,
|
||||
ExitCommand,
|
||||
CounterCommand,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use mlua::{Function, Lua, LuaOptions, MultiValue, Number, Value::Nil};
|
||||
use rustyline::{error::ReadlineError, DefaultEditor};
|
||||
use mlua::{Lua, LuaOptions, MultiValue};
|
||||
use rustyline::{DefaultEditor, error::ReadlineError};
|
||||
|
||||
use crate::core::repl::handler::Command;
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -9,13 +10,10 @@ impl Command for ZLua {
|
|||
fn execute(&self, _args: Option<Vec<String>>) -> Result<(), anyhow::Error> {
|
||||
let time = chrono::Local::now().format("%H:%M:%S.%3f").to_string();
|
||||
let prompt = format!("[{}/{}] {}", time, "ZLUA", ">>\t");
|
||||
let lua = Lua::new_with(
|
||||
mlua::StdLib::ALL_SAFE,
|
||||
LuaOptions::default()
|
||||
)?;
|
||||
let lua = Lua::new_with(mlua::StdLib::ALL_SAFE, LuaOptions::default())?;
|
||||
let globals = lua.globals();
|
||||
//This just adds 2 numbers together
|
||||
let add = lua.create_function(|_, (number1,number2):(i32,i32)|{
|
||||
let add = lua.create_function(|_, (number1, number2): (i32, i32)| {
|
||||
let result = number1 + number2;
|
||||
println!("{result}");
|
||||
Ok(())
|
||||
|
@ -24,23 +22,25 @@ impl Command for ZLua {
|
|||
|
||||
let is_equal = lua.create_function(|_, (list1, list2): (i32, i32)| {
|
||||
if list1 == 0 || list2 == 0 {
|
||||
return Err(mlua::Error::RuntimeError("Zero values not allowed".to_string()));
|
||||
return Err(mlua::Error::RuntimeError(
|
||||
"Zero values not allowed".to_string(),
|
||||
));
|
||||
}
|
||||
Ok(list1 == list2)
|
||||
})?;
|
||||
globals.set("isEqual", is_equal)?;
|
||||
|
||||
let log = lua.create_function(|_, (msg,): (String,)| {
|
||||
println!("{}", msg);
|
||||
Ok(())
|
||||
println!("{}", msg);
|
||||
Ok(())
|
||||
})?;
|
||||
globals.set("log", log)?;
|
||||
|
||||
let fail_safe = lua.create_function(|_,()|{
|
||||
let fail_safe = lua.create_function(|_, ()| {
|
||||
println!("Failed");
|
||||
Ok(())
|
||||
})?;
|
||||
globals.set("failSafe",fail_safe)?;
|
||||
globals.set("failSafe", fail_safe)?;
|
||||
let mut editor = DefaultEditor::new().expect("Failed to create editor");
|
||||
|
||||
loop {
|
||||
|
@ -65,7 +65,7 @@ impl Command for ZLua {
|
|||
mlua::Value::Number(n) => println!("Got number: {}", n),
|
||||
mlua::Value::String(s) => println!("Got string: {}", s.to_str()?),
|
||||
mlua::Value::Boolean(b) => println!("Got boolean: {}", b),
|
||||
_ => eprintln!("Got unexpected type: {:#?}", value)
|
||||
_ => eprintln!("Got unexpected type: {:#?}", value),
|
||||
}
|
||||
}
|
||||
editor.add_history_entry(line).unwrap();
|
||||
|
@ -92,7 +92,6 @@ impl Command for ZLua {
|
|||
eprintln!("Input that caused error: {}", line);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use colored::Colorize;
|
||||
|
||||
pub fn print_splash() {
|
||||
println!
|
||||
("# #
|
||||
println!(
|
||||
"# #
|
||||
# Welcome to the Zenyx terminal #
|
||||
# #");
|
||||
# #"
|
||||
);
|
||||
println!(
|
||||
"{}",
|
||||
format!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue