1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
use clap::{App, Arg, AppSettings};
use crate::{Shell, Arguments};
use crate::errors::*;
use std::env;

pub fn cd(_sh: &mut Shell, args: Arguments) -> Result<()> {
    let matches = App::new("cd")
        .setting(AppSettings::DisableVersion)
        .arg(Arg::with_name("path")
            .required(true)
        )
        .get_matches_from_safe(args)?;

    let path = matches.value_of("path").unwrap();

    env::set_current_dir(&path)?;

    Ok(())
}