»fixed« scratchpad
This commit is contained in:
parent
82a48f5c98
commit
b2cf3621b5
|
@ -207,88 +207,7 @@ pub fn real_shell() {
|
|||
}
|
||||
|
||||
pub fn command_parser(user: String, command: String) {
|
||||
let mut iter = command.split_whitespace();
|
||||
|
||||
let current_path = Path::new("/home/able".to_string());
|
||||
trace!("Current path: {:?}", current_path);
|
||||
let current_path = "/home/able/";
|
||||
|
||||
let bin_name = iter.next().unwrap();
|
||||
|
||||
let mut strin = String::new();
|
||||
for stri in iter.clone() {
|
||||
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
|
||||
// "rhai" => {
|
||||
// shell();
|
||||
// }
|
||||
"list" | "ls" => {
|
||||
let mut vfs = VFS.lock();
|
||||
let handle = vfs.resolve(current_path).unwrap();
|
||||
let dir = vfs.fs_node(handle).unwrap();
|
||||
drop(vfs);
|
||||
for dir_entry in dir.directory().unwrap() {
|
||||
println!("{}", dir_entry.name());
|
||||
}
|
||||
}
|
||||
|
||||
"echo" => match conf_args.1.arguments.get("p") {
|
||||
Some(path) => echo_file(path.to_string()),
|
||||
None => println!("No path provided"),
|
||||
},
|
||||
"test" => {}
|
||||
"quit" => shutdown(),
|
||||
"tree" => filesystem::tree("/").unwrap(),
|
||||
|
||||
_ => {
|
||||
let file = {
|
||||
let mut vfs = VFS.lock();
|
||||
let path = format!("/home/{user}/bins/{bin_name}.wasm");
|
||||
let handle = if let Ok(file) = vfs.resolve(path) {
|
||||
file
|
||||
} else {
|
||||
let path = format!("/shared/bins/{bin_name}.wasm");
|
||||
if let Ok(file) = vfs.resolve(path) {
|
||||
file
|
||||
} else {
|
||||
let path = format!("/system/bins/{bin_name}.wasm");
|
||||
match vfs.resolve(path) {
|
||||
Ok(file) => file,
|
||||
Err(error) => {
|
||||
trace!("{:?}", error);
|
||||
println!("No such binary: {}", bin_name);
|
||||
error!("No such binary: {}", bin_name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
vfs.fs_node(handle).unwrap()
|
||||
};
|
||||
|
||||
let mut binary = vec![];
|
||||
file.read(0, file.size(), &mut binary).unwrap();
|
||||
|
||||
let args = iter.collect::<Vec<&str>>();
|
||||
println!("{:?}", args);
|
||||
run_program(&binary);
|
||||
}
|
||||
}
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
pub fn sound(n_frequency: u32) {
|
||||
|
|
Loading…
Reference in a new issue