Expand pwd command

Expand functionality of the pwd command to better handle the different
types of shells (e.g. FilesystemShell, ValueShell, etc.).
This commit is contained in:
Jonathan Rothberg
2019-09-07 15:31:16 -07:00
parent 90b358d60b
commit 7913ae76f8
7 changed files with 50 additions and 13 deletions

View File

@ -1,7 +1,7 @@
use crate::context::{SourceMap, SpanSource};
use crate::data::Value;
use crate::errors::ShellError;
use crate::evaluate::Scope;
use crate::data::Value;
use crate::parser::hir;
use crate::parser::{registry, ConfigDeserializer};
use crate::prelude::*;

View File

@ -1,9 +1,9 @@
use crate::commands::WholeStreamCommand;
// use crate::data::{Dictionary, Value};
use crate::errors::ShellError;
use crate::data::{Dictionary, Value};
use crate::parser::registry::Signature;
use crate::prelude::*;
use indexmap::IndexMap;
// use indexmap::IndexMap;
pub struct PWD;
@ -30,15 +30,7 @@ impl WholeStreamCommand for PWD {
}
pub fn pwd(args: CommandArgs, registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
let shell_manager = args.shell_manager.clone();
let args = args.evaluate_once(registry)?;
let span = args.call_info.name_span;
let mut indexmap = IndexMap::new();
indexmap.insert(
"name".to_string(),
Tagged::from_simple_spanned_item(Value::string(std::env::current_dir()?.to_string_lossy()), span),
);
let value = Tagged::from_simple_spanned_item(Value::Row(Dictionary::from(indexmap)), span);
Ok(OutputStream::one(value))
shell_manager.pwd(args)
}