cd can be awared inside a value entered.

This commit is contained in:
Andrés N. Robalino
2019-09-03 02:43:37 -05:00
parent 9e3d14cbbf
commit b0a02518f9
3 changed files with 217 additions and 15 deletions

View File

@ -6,6 +6,7 @@ use crate::commands::rm::RemoveArgs;
use crate::context::SourceMap;
use crate::prelude::*;
use crate::shell::shell::Shell;
use crate::utils::ValueStructure;
use std::ffi::OsStr;
use std::path::PathBuf;
@ -103,6 +104,17 @@ impl Shell for ValueShell {
}
};
let mut value_system = ValueStructure::new();
value_system.walk_decorate(&self.value)?;
if !value_system.exists(&PathBuf::from(&path)) {
return Err(ShellError::labeled_error(
"Can not change to path inside",
"No such path exists",
args.call_info.name_span,
));
}
let mut stream = VecDeque::new();
stream.push_back(ReturnSuccess::change_cwd(path));
Ok(stream.into())