Improve enter and fix bugs

This commit is contained in:
Jonathan Turner
2019-08-11 08:18:14 +12:00
parent 357ab46b58
commit 8f78995014
11 changed files with 54 additions and 17 deletions

View File

@ -1,4 +1,5 @@
use crate::commands::command::EvaluatedStaticCommandArgs;
use crate::context::SourceMap;
use crate::object::dir_entry_dict;
use crate::prelude::*;
use crate::shell::completer::NuCompleter;
@ -55,7 +56,7 @@ impl FilesystemShell {
}
impl Shell for FilesystemShell {
fn name(&self) -> String {
fn name(&self, _source_map: &SourceMap) -> String {
"filesystem".to_string()
}

View File

@ -1,9 +1,10 @@
use crate::commands::command::EvaluatedStaticCommandArgs;
use crate::context::SourceMap;
use crate::errors::ShellError;
use crate::stream::OutputStream;
pub trait Shell {
fn name(&self) -> String;
fn name(&self, source_map: &SourceMap) -> String;
fn ls(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError>;
fn cd(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError>;
fn path(&self) -> String;

View File

@ -73,8 +73,8 @@ impl ShellManager {
pub fn next(&mut self) {
{
let mut x = self.shells.lock().unwrap();
let shell = x.pop().unwrap();
x.insert(0, shell);
let shell = x.remove(0);
x.push(shell);
}
self.set_path(self.path());
}
@ -82,8 +82,8 @@ impl ShellManager {
pub fn prev(&mut self) {
{
let mut x = self.shells.lock().unwrap();
let shell = x.remove(0);
x.push(shell);
let shell = x.pop().unwrap();
x.insert(0, shell);
}
self.set_path(self.path());
}

View File

@ -1,4 +1,5 @@
use crate::commands::command::EvaluatedStaticCommandArgs;
use crate::context::SourceMap;
use crate::prelude::*;
use crate::shell::shell::Shell;
use std::ffi::OsStr;
@ -53,8 +54,15 @@ impl ValueShell {
}
impl Shell for ValueShell {
fn name(&self) -> String {
"value".to_string()
fn name(&self, source_map: &SourceMap) -> String {
let origin_name = self.value.origin_name(source_map);
format!(
"{}",
match origin_name {
Some(x) => format!("{{{}}}", x),
None => format!("<{}>", self.value.item.type_name(),),
}
)
}
fn ls(&self, _args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError> {