You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
460 B
26 lines
460 B
use crate::error::ShellError;
|
|
mod cd;
|
|
|
|
const BUILTINS: &[&str] = &["cd"];
|
|
|
|
pub fn is_builtin(keyword: &str) -> bool {
|
|
BUILTINS.contains(&keyword)
|
|
}
|
|
|
|
pub fn execute_builtin(keyword: &str, args: &[&str]) -> Result<(), ShellError> {
|
|
match keyword {
|
|
"cd" => cd::run(args)?,
|
|
_ => {}
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_is_builtin_cd() {
|
|
assert_eq!(is_builtin("cd"), true);
|
|
}
|
|
}
|