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

  1. use crate::error::ShellError;
  2. mod cd;
  3. const BUILTINS: &[&str] = &["cd"];
  4. pub fn is_builtin(keyword: &str) -> bool {
  5. BUILTINS.contains(&keyword)
  6. }
  7. pub fn execute_builtin(keyword: &str, args: &[&str]) -> Result<(), ShellError> {
  8. match keyword {
  9. "cd" => cd::run(args)?,
  10. _ => {}
  11. }
  12. Ok(())
  13. }
  14. #[cfg(test)]
  15. mod tests {
  16. use super::*;
  17. #[test]
  18. fn test_is_builtin_cd() {
  19. assert_eq!(is_builtin("cd"), true);
  20. }
  21. }