2019-08-22 04:13:40 +00:00
|
|
|
use crate::commands::command::EvaluatedWholeStreamCommandArgs;
|
2019-08-21 17:03:59 +00:00
|
|
|
use crate::commands::cp::CopyArgs;
|
|
|
|
use crate::commands::mkdir::MkdirArgs;
|
|
|
|
use crate::commands::mv::MoveArgs;
|
|
|
|
use crate::commands::rm::RemoveArgs;
|
2019-08-10 20:18:14 +00:00
|
|
|
use crate::context::SourceMap;
|
2019-08-07 17:49:11 +00:00
|
|
|
use crate::errors::ShellError;
|
2019-08-21 17:03:59 +00:00
|
|
|
use crate::prelude::*;
|
2019-08-09 20:49:43 +00:00
|
|
|
use crate::stream::OutputStream;
|
2019-08-07 17:49:11 +00:00
|
|
|
|
2019-08-17 03:53:39 +00:00
|
|
|
pub trait Shell: std::fmt::Debug {
|
2019-08-10 20:18:14 +00:00
|
|
|
fn name(&self, source_map: &SourceMap) -> String;
|
2019-08-15 05:02:02 +00:00
|
|
|
fn ls(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError>;
|
|
|
|
fn cd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError>;
|
2019-08-24 19:36:19 +00:00
|
|
|
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>;
|
2019-08-07 17:49:11 +00:00
|
|
|
fn path(&self) -> String;
|
|
|
|
fn set_path(&mut self, path: String);
|
2019-08-09 04:51:21 +00:00
|
|
|
|
2019-08-09 19:42:23 +00:00
|
|
|
fn complete(
|
|
|
|
&self,
|
|
|
|
line: &str,
|
|
|
|
pos: usize,
|
|
|
|
ctx: &rustyline::Context<'_>,
|
|
|
|
) -> Result<(usize, Vec<rustyline::completion::Pair>), rustyline::error::ReadlineError>;
|
2019-08-09 04:51:21 +00:00
|
|
|
|
|
|
|
fn hint(&self, _line: &str, _pos: usize, _ctx: &rustyline::Context<'_>) -> Option<String>;
|
2019-08-07 17:49:11 +00:00
|
|
|
}
|