forked from extern/nushell
Expand functionality of the pwd command to better handle the different types of shells (e.g. FilesystemShell, ValueShell, etc.).
35 lines
1.5 KiB
Rust
35 lines
1.5 KiB
Rust
use crate::commands::command::EvaluatedWholeStreamCommandArgs;
|
|
use crate::commands::cp::CopyArgs;
|
|
use crate::commands::mkdir::MkdirArgs;
|
|
use crate::commands::mv::MoveArgs;
|
|
use crate::commands::rm::RemoveArgs;
|
|
use crate::context::SourceMap;
|
|
use crate::errors::ShellError;
|
|
use crate::prelude::*;
|
|
use crate::stream::OutputStream;
|
|
use std::path::PathBuf;
|
|
|
|
pub trait Shell: std::fmt::Debug {
|
|
fn name(&self, source_map: &SourceMap) -> String;
|
|
fn homedir(&self) -> Option<PathBuf>;
|
|
|
|
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<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 pwd(&self, args: EvaluatedWholeStreamCommandArgs) -> Result<OutputStream, ShellError>;
|
|
fn set_path(&mut self, path: String);
|
|
|
|
fn complete(
|
|
&self,
|
|
line: &str,
|
|
pos: usize,
|
|
ctx: &rustyline::Context<'_>,
|
|
) -> Result<(usize, Vec<rustyline::completion::Pair>), rustyline::error::ReadlineError>;
|
|
|
|
fn hint(&self, _line: &str, _pos: usize, _ctx: &rustyline::Context<'_>) -> Option<String>;
|
|
}
|