Add commands

This commit is contained in:
JT
2021-09-03 10:58:15 +12:00
parent 94687a7603
commit 7c8504ea24
23 changed files with 536 additions and 324 deletions

View File

@ -1,6 +1,6 @@
use crate::{BlockId, Example, ShellError, Signature, Value};
use crate::{ast::Call, BlockId, Example, ShellError, Signature, Value};
use super::CommandArgs;
use super::EvaluationContext;
pub trait Command {
fn name(&self) -> &str;
@ -15,19 +15,12 @@ pub trait Command {
""
}
fn run(&self, args: CommandArgs) -> Result<Value, ShellError>;
// fn run(&self, args: CommandArgs) -> Result<InputStream, ShellError> {
// let context = args.context.clone();
// let stream = self.run_with_actions(args)?;
// Ok(Box::new(crate::evaluate::internal::InternalIterator {
// context,
// input: stream,
// leftovers: InputStream::empty(),
// })
// .into_output_stream())
// }
fn run(
&self,
context: &EvaluationContext,
call: &Call,
input: Value,
) -> Result<Value, ShellError>;
fn is_binary(&self) -> bool {
false

View File

@ -1,7 +0,0 @@
use super::{EvaluationContext, UnevaluatedCallInfo};
pub struct CommandArgs {
pub context: EvaluationContext,
pub call_info: UnevaluatedCallInfo,
pub input: crate::Value,
}

View File

@ -1,11 +1,9 @@
mod call_info;
mod command;
mod command_args;
mod engine_state;
mod evaluation_context;
pub use call_info::*;
pub use command::*;
pub use command_args::*;
pub use engine_state::*;
pub use evaluation_context::*;