switch from reqwest to surf

This commit is contained in:
Jonathan Turner
2019-08-25 07:36:19 +12:00
parent ea86d14673
commit 721a7b159d
17 changed files with 429 additions and 760 deletions

View File

@ -221,7 +221,7 @@ impl Shell for FilesystemShell {
}: CopyArgs,
name: Span,
path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError> {
) -> Result<OutputStream, ShellError> {
let name_span = name;
let mut source = PathBuf::from(path);
@ -491,7 +491,7 @@ impl Shell for FilesystemShell {
}
}
Ok(VecDeque::new())
Ok(OutputStream::empty())
}
fn mkdir(
@ -504,7 +504,7 @@ impl Shell for FilesystemShell {
// }: &RunnablePerItemContext,
name: Span,
path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError> {
) -> Result<OutputStream, ShellError> {
let full_path = PathBuf::from(path);
if directories.len() == 0 {
@ -534,7 +534,7 @@ impl Shell for FilesystemShell {
}
}
Ok(VecDeque::new())
Ok(OutputStream::empty())
}
fn mv(
@ -542,7 +542,7 @@ impl Shell for FilesystemShell {
MoveArgs { src, dst }: MoveArgs,
name: Span,
path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError> {
) -> Result<OutputStream, ShellError> {
let name_span = name;
let mut source = PathBuf::from(path);
@ -837,7 +837,7 @@ impl Shell for FilesystemShell {
}
}
Ok(VecDeque::new())
Ok(OutputStream::empty())
}
fn rm(
@ -845,7 +845,7 @@ impl Shell for FilesystemShell {
RemoveArgs { target, recursive }: RemoveArgs,
name: Span,
path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError> {
) -> Result<OutputStream, ShellError> {
let name_span = name;
if target.item.to_str() == Some(".") || target.item.to_str() == Some("..") {
@ -941,7 +941,7 @@ impl Shell for FilesystemShell {
}
}
Ok(VecDeque::new())
Ok(OutputStream::empty())
}
fn path(&self) -> String {

View File

@ -12,30 +12,10 @@ pub trait Shell: std::fmt::Debug {
fn name(&self, source_map: &SourceMap) -> String;
fn ls(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError>;
fn cd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError>;
fn cp(
&self,
args: CopyArgs,
name: Span,
path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError>;
fn mkdir(
&self,
args: MkdirArgs,
name: Span,
path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError>;
fn mv(
&self,
args: MoveArgs,
name: Span,
path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError>;
fn rm(
&self,
args: RemoveArgs,
name: Span,
path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError>;
fn cp(&self, args: CopyArgs, name: Span, path: &str) -> Result<OutputStream, ShellError>;
fn mkdir(&self, args: MkdirArgs, name: Span, path: &str) -> Result<OutputStream, ShellError>;
fn mv(&self, args: MoveArgs, name: Span, path: &str) -> Result<OutputStream, ShellError>;
fn rm(&self, args: RemoveArgs, name: Span, path: &str) -> Result<OutputStream, ShellError>;
fn path(&self) -> String;
fn set_path(&mut self, path: String);

View File

@ -116,7 +116,7 @@ impl ShellManager {
&self,
args: CopyArgs,
context: &RunnablePerItemContext,
) -> Result<VecDeque<ReturnValue>, ShellError> {
) -> Result<OutputStream, ShellError> {
let env = self.shells.lock();
match env {
@ -136,7 +136,7 @@ impl ShellManager {
&self,
args: RemoveArgs,
context: &RunnablePerItemContext,
) -> Result<VecDeque<ReturnValue>, ShellError> {
) -> Result<OutputStream, ShellError> {
let env = self.shells.lock();
match env {
@ -156,7 +156,7 @@ impl ShellManager {
&self,
args: MkdirArgs,
context: &RunnablePerItemContext,
) -> Result<VecDeque<ReturnValue>, ShellError> {
) -> Result<OutputStream, ShellError> {
let env = self.shells.lock();
match env {
@ -176,7 +176,7 @@ impl ShellManager {
&self,
args: MoveArgs,
context: &RunnablePerItemContext,
) -> Result<VecDeque<ReturnValue>, ShellError> {
) -> Result<OutputStream, ShellError> {
let env = self.shells.lock();
match env {

View File

@ -103,12 +103,7 @@ impl Shell for ValueShell {
Ok(stream.into())
}
fn cp(
&self,
_args: CopyArgs,
name: Span,
_path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError> {
fn cp(&self, _args: CopyArgs, name: Span, _path: &str) -> Result<OutputStream, ShellError> {
Err(ShellError::labeled_error(
"cp not currently supported on values",
"not currently supported",
@ -116,12 +111,7 @@ impl Shell for ValueShell {
))
}
fn mv(
&self,
_args: MoveArgs,
name: Span,
_path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError> {
fn mv(&self, _args: MoveArgs, name: Span, _path: &str) -> Result<OutputStream, ShellError> {
Err(ShellError::labeled_error(
"mv not currently supported on values",
"not currently supported",
@ -129,12 +119,7 @@ impl Shell for ValueShell {
))
}
fn mkdir(
&self,
_args: MkdirArgs,
name: Span,
_path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError> {
fn mkdir(&self, _args: MkdirArgs, name: Span, _path: &str) -> Result<OutputStream, ShellError> {
Err(ShellError::labeled_error(
"mkdir not currently supported on values",
"not currently supported",
@ -142,12 +127,7 @@ impl Shell for ValueShell {
))
}
fn rm(
&self,
_args: RemoveArgs,
name: Span,
_path: &str,
) -> Result<VecDeque<ReturnValue>, ShellError> {
fn rm(&self, _args: RemoveArgs, name: Span, _path: &str) -> Result<OutputStream, ShellError> {
Err(ShellError::labeled_error(
"rm not currently supported on values",
"not currently supported",