nushell/src/commands/command.rs

32 lines
663 B
Rust
Raw Normal View History

2019-05-10 16:59:12 +00:00
use crate::errors::ShellError;
use crate::object::Value;
2019-05-11 08:08:21 +00:00
use std::path::PathBuf;
2019-05-10 16:59:12 +00:00
2019-05-11 08:08:21 +00:00
pub trait CommandBlueprint {
fn create(
&self,
2019-05-12 03:14:16 +00:00
input: crate::Args,
2019-05-10 16:59:12 +00:00
host: &dyn crate::Host,
env: &mut crate::Environment,
2019-05-11 22:59:57 +00:00
) -> Result<Box<dyn Command>, ShellError>;
2019-05-11 08:08:21 +00:00
}
crate enum CommandAction {
ChangeCwd(PathBuf),
}
pub struct CommandSuccess {
crate value: Value,
crate action: Vec<CommandAction>,
}
pub trait Command {
fn begin(&mut self) -> Result<(), ShellError> {
Ok(())
}
fn run(&mut self) -> Result<CommandSuccess, ShellError>;
fn end(&mut self) -> Result<(), ShellError> {
Ok(())
}
2019-05-10 16:59:12 +00:00
}