This commit is contained in:
JT
2021-10-26 05:58:58 +13:00
parent baac60a5a7
commit 5d19017603
59 changed files with 125 additions and 140 deletions

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape, Value};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape};
#[derive(Clone)]
pub struct Alias;
@ -28,7 +28,7 @@ impl Command for Alias {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new())

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape, Value};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape};
#[derive(Clone)]
pub struct Def;
@ -29,7 +29,7 @@ impl Command for Def {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new())

View File

@ -1,6 +1,6 @@
use nu_engine::{eval_block, CallExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape, Value};
#[derive(Clone)]
@ -80,6 +80,6 @@ impl Command for Do {
)
}
}
eval_block(&engine_state, &mut stack, block, input)
eval_block(engine_state, &mut stack, block, input)
}
}

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape, Value};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape};
#[derive(Clone)]
pub struct ExportDef;
@ -29,7 +29,7 @@ impl Command for ExportDef {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new())

View File

@ -1,6 +1,6 @@
use nu_engine::{eval_block, eval_expression};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, IntoPipelineData, PipelineData, Signature, Span, SyntaxShape, Value};
#[derive(Clone)]
@ -56,7 +56,7 @@ impl Command for For {
.expect("internal error: expected block");
let engine_state = engine_state.clone();
let mut stack = stack.enter_scope();
let stack = stack.enter_scope();
match values {
Value::List { vals, span } => Ok(vals

View File

@ -1,6 +1,6 @@
use nu_protocol::{
ast::Call,
engine::{Command, EngineState, EvaluationContext, Stack},
engine::{Command, EngineState, Stack},
span, Example, IntoPipelineData, PipelineData, ShellError, Signature, Spanned, SyntaxShape,
Value,
};

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape, Value};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape};
#[derive(Clone)]
pub struct Hide;
@ -22,7 +22,7 @@ impl Command for Hide {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new())

View File

@ -1,6 +1,6 @@
use nu_engine::{eval_block, eval_expression};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value};
#[derive(Clone)]
@ -41,23 +41,23 @@ impl Command for If {
let result = eval_expression(engine_state, stack, cond)?;
match result {
Value::Bool { val, span } => {
Value::Bool { val, .. } => {
if val {
let block = engine_state.get_block(then_block);
let mut stack = stack.enter_scope();
eval_block(&engine_state, &mut stack, block, input)
eval_block(engine_state, &mut stack, block, input)
} else if let Some(else_case) = else_case {
if let Some(else_expr) = else_case.as_keyword() {
if let Some(block_id) = else_expr.as_block() {
let block = engine_state.get_block(block_id);
let mut stack = stack.enter_scope();
eval_block(&engine_state, &mut stack, block, input)
eval_block(engine_state, &mut stack, block, input)
} else {
eval_expression(&engine_state, stack, else_expr)
eval_expression(engine_state, stack, else_expr)
.map(|x| x.into_pipeline_data())
}
} else {
eval_expression(&engine_state, stack, else_case)
eval_expression(engine_state, stack, else_case)
.map(|x| x.into_pipeline_data())
}
} else {

View File

@ -1,7 +1,7 @@
use nu_engine::eval_expression;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape, Value};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape};
#[derive(Clone)]
pub struct Let;
@ -40,7 +40,7 @@ impl Command for Let {
.as_keyword()
.expect("internal error: missing keyword");
let rhs = eval_expression(&engine_state, stack, keyword_expr)?;
let rhs = eval_expression(engine_state, stack, keyword_expr)?;
//println!("Adding: {:?} to {}", rhs, var_id);

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape, Value};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape};
#[derive(Clone)]
pub struct Module;
@ -28,7 +28,7 @@ impl Command for Module {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new())

View File

@ -1,7 +1,7 @@
use nu_engine::{eval_block, CallExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape, Value};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape};
/// Source a file for environment variables.
#[derive(Clone)]

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, EvaluationContext, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape, Value};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, Signature, SyntaxShape};
#[derive(Clone)]
pub struct Use;
@ -22,7 +22,7 @@ impl Command for Use {
&self,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(PipelineData::new())