This commit is contained in:
JT
2021-10-25 19:31:39 +13:00
parent 397a31e69c
commit b5965ee8ef
60 changed files with 502 additions and 455 deletions

View File

@ -1,6 +1,6 @@
use nu_protocol::{
ast::Call,
engine::{Command, EvaluationContext},
engine::{Command, EngineState, EvaluationContext, Stack},
Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Type, Value,
};
@ -39,7 +39,8 @@ impl Command for SubCommand {
fn run(
&self,
_context: &EvaluationContext,
_engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {

View File

@ -1,7 +1,7 @@
use nu_engine::CallExt;
use nu_protocol::{
ast::Call,
engine::{Command, EvaluationContext},
engine::{Command, EngineState, EvaluationContext, Stack},
IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value,
};
@ -34,22 +34,24 @@ impl Command for SubCommand {
fn run(
&self,
context: &EvaluationContext,
engine_state: &EngineState,
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
split_column(context, call, input)
split_column(engine_state, stack, call, input)
}
}
fn split_column(
context: &EvaluationContext,
engine_state: &EngineState,
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
let name_span = call.head;
let separator: Spanned<String> = call.req(context, 0)?;
let rest: Vec<Spanned<String>> = call.rest(context, 1)?;
let separator: Spanned<String> = call.req(engine_state, stack, 0)?;
let rest: Vec<Spanned<String>> = call.rest(engine_state, stack, 1)?;
let collapse_empty = call.has_flag("collapse-empty");
Ok(input

View File

@ -1,7 +1,7 @@
use nu_engine::get_full_help;
use nu_protocol::{
ast::Call,
engine::{Command, EvaluationContext},
engine::{Command, EngineState, EvaluationContext, Stack},
IntoPipelineData, PipelineData, Signature, Value,
};
@ -23,12 +23,17 @@ impl Command for SplitCommand {
fn run(
&self,
context: &EvaluationContext,
engine_state: &EngineState,
_stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
Ok(Value::String {
val: get_full_help(&SplitCommand.signature(), &SplitCommand.examples(), context),
val: get_full_help(
&SplitCommand.signature(),
&SplitCommand.examples(),
engine_state,
),
span: call.head,
}
.into_pipeline_data())

View File

@ -1,7 +1,7 @@
use nu_engine::CallExt;
use nu_protocol::{
ast::Call,
engine::{Command, EvaluationContext},
engine::{Command, EngineState, EvaluationContext, Stack},
IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value,
};
@ -27,21 +27,23 @@ impl Command for SubCommand {
fn run(
&self,
context: &EvaluationContext,
engine_state: &EngineState,
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
split_row(context, call, input)
split_row(engine_state, stack, call, input)
}
}
fn split_row(
context: &EvaluationContext,
engine_state: &EngineState,
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
let name_span = call.head;
let separator: Spanned<String> = call.req(context, 0)?;
let separator: Spanned<String> = call.req(engine_state, stack, 0)?;
Ok(input
.flat_map(move |x| split_row_helper(&x, &separator, name_span))