|
@ -2,6 +2,7 @@ use crate::error::ShellError; |
|
|
use crate::prompt::PromptStyle;
|
|
|
use crate::prompt::PromptStyle;
|
|
|
use once_cell::unsync::Lazy;
|
|
|
use once_cell::unsync::Lazy;
|
|
|
|
|
|
|
|
|
|
|
|
mod blahaj;
|
|
|
mod cd;
|
|
|
mod cd;
|
|
|
mod change_prompt;
|
|
|
mod change_prompt;
|
|
|
mod exit;
|
|
|
mod exit;
|
|
@ -15,7 +16,7 @@ mod quote; |
|
|
mod segfault;
|
|
|
mod segfault;
|
|
|
mod sus;
|
|
|
mod sus;
|
|
|
mod time;
|
|
|
mod time;
|
|
|
mod blahaj;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct BuiltinConfig {
|
|
|
pub struct BuiltinConfig {
|
|
@ -36,6 +37,7 @@ trait Builtin: Sync + Send { |
|
|
|
|
|
|
|
|
const BUILTINS: Lazy<Vec<(&str, Box<dyn Builtin>)>> = Lazy::new(|| {
|
|
|
const BUILTINS: Lazy<Vec<(&str, Box<dyn Builtin>)>> = Lazy::new(|| {
|
|
|
vec![
|
|
|
vec![
|
|
|
|
|
|
("blahaj", Box::new(blahaj::Blahaj)),
|
|
|
("cd", Box::new(cd::Cd)),
|
|
|
("cd", Box::new(cd::Cd)),
|
|
|
("change-prompt", Box::new(change_prompt::ChangePrompt)),
|
|
|
("change-prompt", Box::new(change_prompt::ChangePrompt)),
|
|
|
("exit", Box::new(exit::Exit)),
|
|
|
("exit", Box::new(exit::Exit)),
|
|
@ -49,7 +51,6 @@ const BUILTINS: Lazy<Vec<(&str, Box<dyn Builtin>)>> = Lazy::new(|| { |
|
|
("segfault", Box::new(segfault::Segfault)),
|
|
|
("segfault", Box::new(segfault::Segfault)),
|
|
|
("sus", Box::new(sus::Sus)),
|
|
|
("sus", Box::new(sus::Sus)),
|
|
|
("time", Box::new(time::Time)),
|
|
|
("time", Box::new(time::Time)),
|
|
|
("blahaj", Box::new(blahaj::Blahaj)),
|
|
|
|
|
|
]
|
|
|
]
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
@ -76,6 +77,12 @@ pub fn execute_builtin( |
|
|
mod tests {
|
|
|
mod tests {
|
|
|
use super::*;
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_is_builtin_blahaj(){
|
|
|
|
|
|
assert!(is_builtin("blahaj"));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_is_builtin_cd() {
|
|
|
fn test_is_builtin_cd() {
|
|
|
assert!(is_builtin("cd"));
|
|
|
assert!(is_builtin("cd"));
|
|
@ -121,6 +128,11 @@ mod tests { |
|
|
assert!(is_builtin("pwd"));
|
|
|
assert!(is_builtin("pwd"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_is_builtin_quote() {
|
|
|
|
|
|
assert!(is_builtin("quote"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_is_builtin_segfault() {
|
|
|
fn test_is_builtin_segfault() {
|
|
|
assert!(is_builtin("segfault"));
|
|
|
assert!(is_builtin("segfault"));
|
|
@ -131,11 +143,6 @@ mod tests { |
|
|
assert!(is_builtin("sus"));
|
|
|
assert!(is_builtin("sus"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_is_builtin_quote() {
|
|
|
|
|
|
assert!(is_builtin("quote"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_is_builtin_time() {
|
|
|
fn test_is_builtin_time() {
|
|
|
assert!(is_builtin("time"));
|
|
|
assert!(is_builtin("time"));
|
|
@ -146,8 +153,3 @@ mod tests { |
|
|
assert!(!is_builtin("notabuiltin"))
|
|
|
assert!(!is_builtin("notabuiltin"))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_is_builtin_blahaj(){
|
|
|
|
|
|
assert!(is_builtin("blahaj"));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|