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.

15 lines
402 B

  1. use crate::error::ShellError;
  2. use super::{Builtin, BuiltinConfig};
  3. pub struct Pwd;
  4. impl Builtin for Pwd {
  5. fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> {
  6. match std::env::current_dir() {
  7. Ok(p) => println!("{}", p.display()),
  8. Err(e) => return Err(ShellError::ExecuteFailure(e.to_string())),
  9. }
  10. Ok(())
  11. }
  12. }