Add basic commands
This commit is contained in:
parent
fcb457efff
commit
4c16ae534c
32
src/shell.rs
32
src/shell.rs
|
@ -1,14 +1,42 @@
|
||||||
use crate::println;
|
use crate::println;
|
||||||
use crate::print;
|
use crate::print;
|
||||||
|
use crate::vga_buffer::{change_color, Color};
|
||||||
|
|
||||||
pub fn evaluate(command: &str) {
|
pub fn evaluate(command: &str) {
|
||||||
if let Some(stripped) = command.strip_prefix(">>> ") {
|
if let Some(stripped) = command.strip_prefix(">>> ") {
|
||||||
let res = stripped.trim();
|
let res = stripped.trim();
|
||||||
if res != "" {
|
if res != "" {
|
||||||
println!();
|
println!();
|
||||||
println!();
|
let selected = match res {
|
||||||
println!("[ {} ]", res);
|
"help" => help,
|
||||||
|
"info" => info,
|
||||||
|
_ => default
|
||||||
|
};
|
||||||
|
selected();
|
||||||
print!(">>> ");
|
print!(">>> ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default() {
|
||||||
|
println!("Error: unknown command.");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn help() {
|
||||||
|
change_color(Color::LightBlue, Color::Black);
|
||||||
|
print!("KarxShell help menu\n\n");
|
||||||
|
println!("[help] This message");
|
||||||
|
change_color(Color::White, Color::Black);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn info() {
|
||||||
|
print!("KarxOS by ");
|
||||||
|
change_color(Color::Blue, Color::Black);
|
||||||
|
println!("karx (karx1 on GitHub)");
|
||||||
|
change_color(Color::White, Color::Black);
|
||||||
|
print!("Developed for a science project in the ");
|
||||||
|
change_color(Color::Red, Color::Black);
|
||||||
|
println!("Rust language.");
|
||||||
|
change_color(Color::White, Color::Black);
|
||||||
|
println!("If you're having input problems, switch to a US keyboard layout.");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue