2024-12-01 23:52:12 -06:00
|
|
|
use super::COMMAND_LIST;
|
2024-12-01 16:02:06 -05:00
|
|
|
use std::process::Command;
|
|
|
|
use log2::{debug, info};
|
|
|
|
|
2024-12-01 23:52:12 -06:00
|
|
|
pub(crate) fn say_hello() {
|
|
|
|
println!("Hello, World!");
|
2024-12-01 16:02:06 -05:00
|
|
|
}
|
|
|
|
|
2024-12-01 23:52:12 -06:00
|
|
|
pub(crate) fn echo(args: Vec<String>) {
|
2024-12-01 16:02:06 -05:00
|
|
|
debug!("{}", args.join(" "));
|
|
|
|
println!("{}", args.join(" "))
|
|
|
|
}
|
|
|
|
|
2024-12-01 23:52:12 -06:00
|
|
|
pub(crate) fn exit() {
|
2024-12-01 16:02:06 -05:00
|
|
|
debug!("Exiting...");
|
|
|
|
std::process::exit(0)
|
|
|
|
}
|
2024-12-01 23:52:12 -06:00
|
|
|
|
|
|
|
pub(crate) fn clear() {
|
2024-12-01 16:02:06 -05:00
|
|
|
info!("Clearing screen..., running command");
|
|
|
|
let _result = if cfg!(target_os = "windows") {
|
|
|
|
debug!("target_os is windows");
|
|
|
|
Command::new("cmd").args(["/c", "cls"]).spawn()
|
|
|
|
} else {
|
2024-12-01 23:52:12 -06:00
|
|
|
debug!("target_os is unix");
|
2024-12-01 16:02:06 -05:00
|
|
|
// "clear" or "tput reset"
|
|
|
|
Command::new("tput").arg("reset").spawn()
|
|
|
|
};
|
|
|
|
}
|
2024-12-01 23:52:12 -06:00
|
|
|
|
|
|
|
pub(crate) fn help() {
|
2024-12-01 16:02:06 -05:00
|
|
|
println!("Commands:");
|
|
|
|
for cmd in COMMAND_LIST.commands.read().iter() {
|
|
|
|
println!("{:#}", cmd);
|
|
|
|
}
|
|
|
|
}
|