build: remove regex dependency in favor of rust iterators

This commit is contained in:
Chance 2025-04-07 22:11:38 -04:00
parent 29f1cf68bf
commit 7c3fa95566
Signed by: caznix
GPG key ID: 489D213143D753FD
5 changed files with 90 additions and 75 deletions

View file

@ -6,7 +6,6 @@ use std::{
use chrono::Local;
use colored::Colorize;
use parking_lot::Mutex;
use regex::Regex;
use rustyline::{
Cmd, Completer, ConditionalEventHandler, Editor, Event, EventContext, EventHandler, Helper,
Hinter, KeyEvent, RepeatCount, Validator, completion::Completer, error::ReadlineError,
@ -131,12 +130,10 @@ pub fn tokenize(command: &str) -> Vec<String> {
}
pub fn parse_command(input: &str) -> Result<Vec<String>> {
let pattern = Regex::new(r"[;|\n]").map_err(|_| {
ZenyxError::builder(ZenyxErrorKind::CommandParsing)
.with_message("Failed to compile regex pattern")
.build()
})?;
let commands: Vec<String> = pattern.split(input).map(String::from).collect();
let commands = input
.split(|c| c == ';' || c == '\n')
.map(|slice| slice.to_string())
.collect::<Vec<String>>();
Ok(commands)
}
@ -145,12 +142,10 @@ pub fn evaluate_command(input: &str) -> Result<()> {
return Ok(());
}
let pattern = Regex::new(r"[;|\n]").map_err(|_| {
ZenyxError::builder(ZenyxErrorKind::CommandParsing)
.with_message("Failed to compile regex pattern")
.build()
})?;
let commands: Vec<&str> = pattern.split(input).collect();
let commands = input
.split(|c| c == ';' || c == '\n')
.map(|slice| slice.to_string())
.collect::<Vec<String>>();
for command in commands {
let command = command.trim();