port clparse

This commit is contained in:
able 2022-08-06 22:12:48 -05:00
parent e8221f8513
commit e768c308e6
9 changed files with 53 additions and 19 deletions

11
Cargo.lock generated
View file

@ -31,6 +31,7 @@ dependencies = [
"axel",
"bitflags",
"bootloader",
"clparse",
"cpuio",
"ext2",
"externc-libm",
@ -161,6 +162,16 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clparse"
version = "0.1.0"
source = "git+https://git.ablecorp.us/able/core_utils#46a97f827bd11f3cea8dcab797b9697d9485c4b3"
dependencies = [
"hashbrown",
"log",
"toml",
]
[[package]]
name = "colored"
version = "2.0.0"

View file

@ -71,6 +71,8 @@ versioning = { git = "https://git.ablecorp.us/able/aos_userland" }
# embedded-graphics = "*"
pc-keyboard = "0.5"
# mini-backtrace = "0.1"
clparse = { git = "https://git.ablecorp.us/able/core_utils", default-features = false }
[dependencies.linked_list_allocator]
version = "0.9.0"

View file

@ -6,6 +6,7 @@ user_processes = ["shell"]
enabled = true
level = "Trace"
log_to_serial = true
log_to_vterm = false
filter = ["ableos::ps2_mouse", "ableos::vterm"]

View file

@ -140,7 +140,6 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
DecodedKey::Unicode(chr) => match chr {
'\n' => {
KEYBUFF.lock().push('\n');
trace!("ENTER");
}
// Backspace
'\u{8}' => {

View file

@ -52,6 +52,7 @@ impl Default for KernelConfig {
pub struct LoggingConfig {
pub enabled: bool,
pub log_to_serial: bool,
pub log_to_vterm: bool,
pub level: LogLevel,
pub filter: Vec<String>,
}

View file

@ -17,3 +17,4 @@ impl DeviceID {
}
pub const VMWARE_SVGA2: DeviceID = DeviceID::new(VMware, 0x0405);
pub const S3INC_TRIO64V2: DeviceID = DeviceID::new(S3Inc, 0x8900);

View file

@ -9,7 +9,7 @@ use super::devices::*;
pub fn check_pci_support(device_id: DeviceID) -> bool {
match device_id {
VMWARE_SVGA2 => true,
S3INC_TRIO64V2 => true,
_ => false,
}
}

View file

@ -47,18 +47,20 @@ impl log::Log for SimpleLogger {
None => 0,
};
let msg = format!(
// "[{}{}$RESET$][$GREEN${}$RESET$]{}\n",
"[{}{:05}\0RESET\0][\0GREEN\0{}\0RESET\0][\0BLUE\0{}@{}\0RESET\0] {}",
color.1,
record.level(),
time_float,
mod_path,
line,
record.args(),
);
if KERNEL_CONF.logging.log_to_vterm {
let msg = format!(
// "[{}{}$RESET$][$GREEN${}$RESET$]{}\n",
"[{}{:05}\0RESET\0][\0GREEN\0{}\0RESET\0][\0BLUE\0{}@{}\0RESET\0] {}",
color.1,
record.level(),
time_float,
mod_path,
line,
record.args(),
);
// println!("{msg}");
println!("{msg}");
}
if KERNEL_CONF.logging.log_to_serial {
serial_println!(

View file

@ -7,7 +7,6 @@
use crate::arch::drivers::sysinfo::master;
use crate::arch::interrupts::{reset_pit_for_cpu, set_pit_2};
use crate::devices::pci::brute_force_scan;
use crate::image::mono_bitmap::bruh;
use crate::systeminfo::{KERNEL_VERSION, RELEASE_TYPE};
use crate::time::fetch_time;
use crate::KERNEL_STATE;
@ -204,6 +203,21 @@ pub fn command_parser(user: String, command: String) {
let bin_name = iter.next().unwrap();
let mut strin = String::new();
for stri in iter {
trace!("{}", stri);
strin.push_str(stri);
}
let conf_args;
match clparse::Arguments::parse_from_string(strin) {
Ok(ok) => conf_args = ok,
Err(err) => {
println!("ERROR: {}", err);
error!("{}", err);
return;
}
};
match bin_name {
// note: able asked for rhaish to stay in the repo but will be removed
// in the future so just comment it out for now
@ -217,9 +231,12 @@ pub fn command_parser(user: String, command: String) {
}
}
"echo" => {
echo_file(iter.next().unwrap().to_string(), fs);
}
"echo" => match conf_args.1.arguments.get("p") {
Some(path) => echo_file(path.to_string(), fs),
None => println!("No path provided"),
},
"test" => {}
"quit" => shutdown(),
@ -252,8 +269,8 @@ pub fn command_parser(user: String, command: String) {
let mut binary = vec![];
file.read_to_end(&mut binary).unwrap();
let args = iter.collect::<Vec<&str>>();
println!("{:?}", args);
// let args = iter.collect::<Vec<&str>>();
// println!("{:?}", args);
run_program(&binary);
}
}