mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 19:17:44 +02:00
WIP
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::commands::command::EvaluatedStaticCommandArgs;
|
||||
use crate::commands::command::EvaluatedWholeStreamCommandArgs;
|
||||
use crate::context::SourceMap;
|
||||
use crate::object::dir_entry_dict;
|
||||
use crate::prelude::*;
|
||||
@ -60,7 +60,7 @@ impl Shell for FilesystemShell {
|
||||
"filesystem".to_string()
|
||||
}
|
||||
|
||||
fn ls(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
fn ls(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let cwd = self.path.clone();
|
||||
let mut full_path = PathBuf::from(&self.path);
|
||||
match &args.nth(0) {
|
||||
@ -133,7 +133,7 @@ impl Shell for FilesystemShell {
|
||||
Ok(shell_entries.to_output_stream())
|
||||
}
|
||||
|
||||
fn cd(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
fn cd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let path = match args.nth(0) {
|
||||
None => match dirs::home_dir() {
|
||||
Some(o) => o,
|
||||
|
@ -1,12 +1,12 @@
|
||||
use crate::commands::command::EvaluatedStaticCommandArgs;
|
||||
use crate::commands::command::EvaluatedWholeStreamCommandArgs;
|
||||
use crate::context::SourceMap;
|
||||
use crate::errors::ShellError;
|
||||
use crate::stream::OutputStream;
|
||||
|
||||
pub trait Shell {
|
||||
fn name(&self, source_map: &SourceMap) -> String;
|
||||
fn ls(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError>;
|
||||
fn cd(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError>;
|
||||
fn ls(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError>;
|
||||
fn cd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError>;
|
||||
fn path(&self) -> String;
|
||||
fn set_path(&mut self, path: String);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::commands::command::EvaluatedStaticCommandArgs;
|
||||
use crate::commands::command::EvaluatedWholeStreamCommandArgs;
|
||||
use crate::errors::ShellError;
|
||||
use crate::prelude::*;
|
||||
use crate::shell::filesystem_shell::FilesystemShell;
|
||||
@ -88,12 +88,12 @@ impl ShellManager {
|
||||
self.set_path(self.path());
|
||||
}
|
||||
|
||||
pub fn ls(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
pub fn ls(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let env = self.shells.lock().unwrap();
|
||||
|
||||
env.last().unwrap().ls(args)
|
||||
}
|
||||
pub fn cd(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
pub fn cd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let env = self.shells.lock().unwrap();
|
||||
|
||||
env.last().unwrap().cd(args)
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::commands::command::EvaluatedStaticCommandArgs;
|
||||
use crate::commands::command::EvaluatedWholeStreamCommandArgs;
|
||||
use crate::context::SourceMap;
|
||||
use crate::prelude::*;
|
||||
use crate::shell::shell::Shell;
|
||||
@ -65,14 +65,14 @@ impl Shell for ValueShell {
|
||||
)
|
||||
}
|
||||
|
||||
fn ls(&self, _args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
fn ls(&self, _args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
Ok(self
|
||||
.members()
|
||||
.map(|x| ReturnSuccess::value(x))
|
||||
.to_output_stream())
|
||||
}
|
||||
|
||||
fn cd(&self, args: EvaluatedStaticCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
fn cd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError> {
|
||||
let path = match args.nth(0) {
|
||||
None => "/".to_string(),
|
||||
Some(v) => {
|
||||
|
Reference in New Issue
Block a user