nushell/src/commands/cd.rs

22 lines
536 B
Rust
Raw Normal View History

2019-05-11 09:00:33 +02:00
use crate::errors::ShellError;
use crate::object::process::Process;
use crate::object::{DirEntry, ShellObject, Value};
use derive_new::new;
use std::path::{Path, PathBuf};
use sysinfo::SystemExt;
#[derive(new)]
pub struct Cd;
impl crate::Command for Cd {
fn run(
&mut self,
args: Vec<String>,
_host: &dyn crate::Host,
env: &mut crate::Environment,
) -> Result<Value, ShellError> {
env.cwd = dunce::canonicalize(env.cwd().join(&args[0]).as_path())?;
Ok(Value::nothing())
}
}