forked from extern/nushell
Remove EvaluationContext::from_args (#3604)
This commit is contained in:
parent
8ac572ed27
commit
b9ca3b2039
@ -52,7 +52,7 @@ impl WholeStreamCommand for Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn all(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn all(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
let all_args = AllArgs {
|
let all_args = AllArgs {
|
||||||
predicate: args.req(0)?,
|
predicate: args.req(0)?,
|
||||||
|
@ -52,7 +52,7 @@ impl WholeStreamCommand for Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn any(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn any(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
let any_args = AnyArgs {
|
let any_args = AnyArgs {
|
||||||
predicate: args.req(0)?,
|
predicate: args.req(0)?,
|
||||||
|
@ -23,7 +23,7 @@ impl WholeStreamCommand for AutoenvTrust {
|
|||||||
|
|
||||||
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
|
|
||||||
let file_to_trust = match args.call_info.evaluate(&ctx)?.args.nth(0) {
|
let file_to_trust = match args.call_info.evaluate(&ctx)?.args.nth(0) {
|
||||||
Some(Value {
|
Some(Value {
|
||||||
|
@ -27,7 +27,7 @@ impl WholeStreamCommand for AutoenvUnTrust {
|
|||||||
|
|
||||||
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
let file_to_untrust = match args.call_info.evaluate(&ctx)?.args.nth(0) {
|
let file_to_untrust = match args.call_info.evaluate(&ctx)?.args.nth(0) {
|
||||||
Some(Value {
|
Some(Value {
|
||||||
value: UntaggedValue::Primitive(Primitive::String(ref path)),
|
value: UntaggedValue::Primitive(Primitive::String(ref path)),
|
||||||
|
@ -71,7 +71,7 @@ impl WholeStreamCommand for Benchmark {
|
|||||||
|
|
||||||
fn benchmark(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn benchmark(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let tag = args.call_info.args.span;
|
let tag = args.call_info.args.span;
|
||||||
let mut context = EvaluationContext::from_args(&args);
|
let mut context = args.context.clone();
|
||||||
let scope = args.scope().clone();
|
let scope = args.scope().clone();
|
||||||
|
|
||||||
let cmd_args = BenchmarkArgs {
|
let cmd_args = BenchmarkArgs {
|
||||||
|
@ -33,7 +33,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
|
|
||||||
pub fn clear(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
pub fn clear(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let name = args.call_info.name_tag.clone();
|
let name = args.call_info.name_tag.clone();
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
|
|
||||||
let result = if let Some(global_cfg) = &mut args.configs().lock().global_config {
|
let result = if let Some(global_cfg) = &mut args.configs().lock().global_config {
|
||||||
global_cfg.vars.clear();
|
global_cfg.vars.clear();
|
||||||
|
@ -37,7 +37,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
|
|
||||||
pub fn get(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
pub fn get(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let name = args.call_info.name_tag.clone();
|
let name = args.call_info.name_tag.clone();
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
|
|
||||||
let column_path = args.req(0)?;
|
let column_path = args.req(0)?;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
|
|
||||||
pub fn remove(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
pub fn remove(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let name = args.call_info.name_tag.clone();
|
let name = args.call_info.name_tag.clone();
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
let remove: Tagged<String> = args.req(0)?;
|
let remove: Tagged<String> = args.req(0)?;
|
||||||
|
|
||||||
let key = remove.to_string();
|
let key = remove.to_string();
|
||||||
|
@ -52,7 +52,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
|
|
||||||
pub fn set(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
pub fn set(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let name = args.call_info.name_tag.clone();
|
let name = args.call_info.name_tag.clone();
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
|
|
||||||
let column_path = args.req(0)?;
|
let column_path = args.req(0)?;
|
||||||
let mut value: Value = args.req(1)?;
|
let mut value: Value = args.req(1)?;
|
||||||
|
@ -38,7 +38,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
|
|
||||||
pub fn set_into(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
pub fn set_into(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let name = args.call_info.name_tag.clone();
|
let name = args.call_info.name_tag.clone();
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
|
|
||||||
let set_into: Tagged<String> = args.req(0)?;
|
let set_into: Tagged<String> = args.req(0)?;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ impl WholeStreamCommand for EachWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&self, mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn run(&self, mut args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
let context = Arc::new(args.context.clone());
|
||||||
let external_redirection = args.call_info.args.external_redirection;
|
let external_redirection = args.call_info.args.external_redirection;
|
||||||
|
|
||||||
let window_size: Tagged<usize> = args.req(0)?;
|
let window_size: Tagged<usize> = args.req(0)?;
|
||||||
|
@ -82,23 +82,21 @@ impl WholeStreamCommand for Command {
|
|||||||
|
|
||||||
fn is_empty(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn is_empty(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
let name_tag = Arc::new(args.call_info.name_tag.clone());
|
let context = args.context.clone();
|
||||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
|
||||||
let block: Option<CapturedBlock> = args.get_flag("block")?;
|
let block: Option<CapturedBlock> = args.get_flag("block")?;
|
||||||
let columns: Vec<ColumnPath> = args.rest(0)?;
|
let columns: Vec<ColumnPath> = args.rest(0)?;
|
||||||
|
|
||||||
let input = args.input;
|
let input = args.input;
|
||||||
|
|
||||||
if input.is_empty() {
|
if input.is_empty() {
|
||||||
let stream = vec![UntaggedValue::Primitive(Primitive::Nothing).into_value(tag)].into_iter();
|
let stream =
|
||||||
|
vec![UntaggedValue::Primitive(Primitive::Nothing).into_value(&tag)].into_iter();
|
||||||
|
|
||||||
return Ok(InputStream::from_stream(stream)
|
return Ok(InputStream::from_stream(stream)
|
||||||
.map(move |input| {
|
.map(move |input| {
|
||||||
let tag = name_tag.clone();
|
|
||||||
let context = context.clone();
|
|
||||||
let columns = vec![];
|
let columns = vec![];
|
||||||
|
|
||||||
match process_row(context, input, &block, columns, tag) {
|
match process_row(&context, input, &block, columns) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => ActionStream::one(Err(e)),
|
Err(e) => ActionStream::one(Err(e)),
|
||||||
}
|
}
|
||||||
@ -109,11 +107,9 @@ fn is_empty(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
|||||||
|
|
||||||
Ok(input
|
Ok(input
|
||||||
.map(move |input| {
|
.map(move |input| {
|
||||||
let tag = name_tag.clone();
|
|
||||||
let context = context.clone();
|
|
||||||
let columns = columns.clone();
|
let columns = columns.clone();
|
||||||
|
|
||||||
match process_row(context, input, &block, columns, tag) {
|
match process_row(&context, input, &block, columns) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => ActionStream::one(Err(e)),
|
Err(e) => ActionStream::one(Err(e)),
|
||||||
}
|
}
|
||||||
@ -123,13 +119,11 @@ fn is_empty(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn process_row(
|
fn process_row(
|
||||||
context: Arc<EvaluationContext>,
|
context: &EvaluationContext,
|
||||||
input: Value,
|
input: Value,
|
||||||
default_block: &Option<CapturedBlock>,
|
default_block: &Option<CapturedBlock>,
|
||||||
column_paths: Vec<ColumnPath>,
|
column_paths: Vec<ColumnPath>,
|
||||||
tag: Arc<Tag>,
|
|
||||||
) -> Result<ActionStream, ShellError> {
|
) -> Result<ActionStream, ShellError> {
|
||||||
let _tag = &*tag;
|
|
||||||
let mut out = Arc::new(None);
|
let mut out = Arc::new(None);
|
||||||
let results = Arc::make_mut(&mut out);
|
let results = Arc::make_mut(&mut out);
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ impl WholeStreamCommand for ForIn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_row(
|
pub fn process_row(
|
||||||
captured_block: Arc<Box<CapturedBlock>>,
|
captured_block: &CapturedBlock,
|
||||||
context: Arc<EvaluationContext>,
|
context: &EvaluationContext,
|
||||||
input: Value,
|
input: Value,
|
||||||
var_name: &str,
|
var_name: &str,
|
||||||
external_redirection: ExternalRedirection,
|
external_redirection: ExternalRedirection,
|
||||||
@ -108,12 +108,12 @@ pub(crate) fn make_indexed_item(index: usize, item: Value) -> Value {
|
|||||||
dict.into_value()
|
dict.into_value()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn for_in(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn for_in(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let context = Arc::new(EvaluationContext::from_args(&raw_args));
|
let context = args.context.clone();
|
||||||
let external_redirection = raw_args.call_info.args.external_redirection;
|
let external_redirection = args.call_info.args.external_redirection;
|
||||||
//
|
//
|
||||||
let numbered: bool = raw_args.call_info.switch_present("numbered");
|
let numbered: bool = args.call_info.switch_present("numbered");
|
||||||
let positional = raw_args
|
let positional = args
|
||||||
.call_info
|
.call_info
|
||||||
.args
|
.args
|
||||||
.positional
|
.positional
|
||||||
@ -126,17 +126,14 @@ fn for_in(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|||||||
FromValue::from_value(&evaluate_baseline_expr(&positional[3], &context)?)?;
|
FromValue::from_value(&evaluate_baseline_expr(&positional[3], &context)?)?;
|
||||||
|
|
||||||
let input = crate::commands::echo::expand_value_to_stream(rhs);
|
let input = crate::commands::echo::expand_value_to_stream(rhs);
|
||||||
let block = Arc::new(Box::new(block));
|
|
||||||
|
|
||||||
if numbered {
|
if numbered {
|
||||||
Ok(input
|
Ok(input
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(move |input| {
|
.map(move |input| {
|
||||||
let block = block.clone();
|
|
||||||
let context = context.clone();
|
|
||||||
let row = make_indexed_item(input.0, input.1);
|
let row = make_indexed_item(input.0, input.1);
|
||||||
|
|
||||||
match process_row(block, context, row, &var_name, external_redirection) {
|
match process_row(&block, &context, row, &var_name, external_redirection) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => OutputStream::one(Value::error(e)),
|
Err(e) => OutputStream::one(Value::error(e)),
|
||||||
}
|
}
|
||||||
@ -147,9 +144,8 @@ fn for_in(raw_args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|||||||
Ok(input
|
Ok(input
|
||||||
.map(move |input| {
|
.map(move |input| {
|
||||||
let block = block.clone();
|
let block = block.clone();
|
||||||
let context = context.clone();
|
|
||||||
|
|
||||||
match process_row(block, context, input, &var_name, external_redirection) {
|
match process_row(&block, &context, input, &var_name, external_redirection) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(e) => OutputStream::one(Value::error(e)),
|
Err(e) => OutputStream::one(Value::error(e)),
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ impl WholeStreamCommand for Format {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn format_command(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn format_command(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let ctx = Arc::new(EvaluationContext::from_args(&args));
|
let ctx = Arc::new(args.context.clone());
|
||||||
let pattern: Tagged<String> = args.req(0)?;
|
let pattern: Tagged<String> = args.req(0)?;
|
||||||
|
|
||||||
let format_pattern = format(&pattern);
|
let format_pattern = format(&pattern);
|
||||||
|
@ -125,7 +125,7 @@ enum Grouper {
|
|||||||
|
|
||||||
pub fn group_by(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
pub fn group_by(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let name = args.call_info.name_tag.clone();
|
let name = args.call_info.name_tag.clone();
|
||||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
let context = Arc::new(args.context.clone());
|
||||||
|
|
||||||
let grouper = args.opt(0)?;
|
let grouper = args.opt(0)?;
|
||||||
let values: Vec<Value> = args.input.collect();
|
let values: Vec<Value> = args.input.collect();
|
||||||
|
@ -27,7 +27,7 @@ impl WholeStreamCommand for History {
|
|||||||
|
|
||||||
fn history(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn history(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
|
|
||||||
let clear = args.has_flag("clear");
|
let clear = args.has_flag("clear");
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ fn process_row(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn insert(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn insert(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
let context = Arc::new(args.context.clone());
|
||||||
let column: ColumnPath = args.req(0)?;
|
let column: ColumnPath = args.req(0)?;
|
||||||
let value: Value = args.req(1)?;
|
let value: Value = args.req(1)?;
|
||||||
let input = args.input;
|
let input = args.input;
|
||||||
|
@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let ctx = Arc::new(EvaluationContext::from_args(&args));
|
let ctx = Arc::new(args.context.clone());
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
let block: CapturedBlock = args.req(0)?;
|
let block: CapturedBlock = args.req(0)?;
|
||||||
|
@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let ctx = Arc::new(EvaluationContext::from_args(&args));
|
let ctx = Arc::new(args.context.clone());
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
let block: CapturedBlock = args.req(0)?;
|
let block: CapturedBlock = args.req(0)?;
|
||||||
|
@ -55,7 +55,7 @@ impl WholeStreamCommand for Let {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn letcmd(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
pub fn letcmd(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
let positional = args
|
let positional = args
|
||||||
.call_info
|
.call_info
|
||||||
.args
|
.args
|
||||||
|
@ -49,7 +49,7 @@ impl WholeStreamCommand for LetEnv {
|
|||||||
|
|
||||||
pub fn set_env(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
pub fn set_env(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
|
|
||||||
let name: Tagged<String> = args.req(0)?;
|
let name: Tagged<String> = args.req(0)?;
|
||||||
let rhs: CapturedBlock = args.req(2)?;
|
let rhs: CapturedBlock = args.req(2)?;
|
||||||
|
@ -82,7 +82,7 @@ fn load_env_from_table(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_env(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
pub fn load_env(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
|
|
||||||
if let Some(values) = args.opt::<Vec<Value>>(0)? {
|
if let Some(values) = args.opt::<Vec<Value>>(0)? {
|
||||||
load_env_from_table(values, &ctx)?;
|
load_env_from_table(values, &ctx)?;
|
||||||
|
@ -42,7 +42,7 @@ impl WholeStreamCommand for Merge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn merge(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn merge(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let context = EvaluationContext::from_args(&args);
|
let context = &args.context;
|
||||||
let name_tag = args.call_info.name_tag.clone();
|
let name_tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
let block: CapturedBlock = args.req(0)?;
|
let block: CapturedBlock = args.req(0)?;
|
||||||
|
@ -108,7 +108,7 @@ fn process_row(
|
|||||||
|
|
||||||
fn reduce(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn reduce(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let span = args.call_info.name_tag.span;
|
let span = args.call_info.name_tag.span;
|
||||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
let context = Arc::new(args.context.clone());
|
||||||
let reduce_args = ReduceArgs {
|
let reduce_args = ReduceArgs {
|
||||||
block: args.req(0)?,
|
block: args.req(0)?,
|
||||||
fold: args.get_flag("fold")?,
|
fold: args.get_flag("fold")?,
|
||||||
|
@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let ctx = Arc::new(EvaluationContext::from_args(&args));
|
let ctx = Arc::new(args.context.clone());
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
let block: CapturedBlock = args.req(0)?;
|
let block: CapturedBlock = args.req(0)?;
|
||||||
|
@ -30,7 +30,7 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn run_with_actions(&self, args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let ctx = Arc::new(EvaluationContext::from_args(&args));
|
let ctx = Arc::new(args.context.clone());
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
let block: CapturedBlock = args.req(0)?;
|
let block: CapturedBlock = args.req(0)?;
|
||||||
|
@ -40,7 +40,7 @@ impl WholeStreamCommand for Source {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn source(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
pub fn source(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
let filename: Tagged<String> = args.req(0)?;
|
let filename: Tagged<String> = args.req(0)?;
|
||||||
|
|
||||||
// Note: this is a special case for setting the context from a command
|
// Note: this is a special case for setting the context from a command
|
||||||
|
@ -174,7 +174,7 @@ fn process_row(
|
|||||||
|
|
||||||
fn update(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn update(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let name_tag = Arc::new(args.call_info.name_tag.clone());
|
let name_tag = Arc::new(args.call_info.name_tag.clone());
|
||||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
let context = Arc::new(args.context.clone());
|
||||||
|
|
||||||
let field: ColumnPath = args.req(0)?;
|
let field: ColumnPath = args.req(0)?;
|
||||||
let replacement: Value = args.req(1)?;
|
let replacement: Value = args.req(1)?;
|
||||||
|
@ -57,7 +57,7 @@ impl WholeStreamCommand for Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn where_command(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
fn where_command(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
||||||
let context = Arc::new(EvaluationContext::from_args(&args));
|
let context = Arc::new(args.context.clone());
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
let block: CapturedBlock = args.req(0)?;
|
let block: CapturedBlock = args.req(0)?;
|
||||||
|
@ -69,7 +69,7 @@ impl WholeStreamCommand for WithEnv {
|
|||||||
|
|
||||||
fn with_env(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
fn with_env(args: CommandArgs) -> Result<ActionStream, ShellError> {
|
||||||
let external_redirection = args.call_info.args.external_redirection;
|
let external_redirection = args.call_info.args.external_redirection;
|
||||||
let context = EvaluationContext::from_args(&args);
|
let context = &args.context;
|
||||||
let variable: Value = args.req(0)?;
|
let variable: Value = args.req(0)?;
|
||||||
let block: CapturedBlock = args.req(1)?;
|
let block: CapturedBlock = args.req(1)?;
|
||||||
|
|
||||||
|
@ -67,10 +67,6 @@ impl EvaluationContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_args(args: &CommandArgs) -> EvaluationContext {
|
|
||||||
args.context.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn error(&self, error: ShellError) {
|
pub fn error(&self, error: ShellError) {
|
||||||
self.with_errors(|errors| errors.push(error))
|
self.with_errors(|errors| errors.push(error))
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use crate::command_args::CommandArgs;
|
use crate::command_args::CommandArgs;
|
||||||
use crate::documentation::get_full_help;
|
use crate::documentation::get_full_help;
|
||||||
use crate::evaluate::block::run_block;
|
use crate::evaluate::block::run_block;
|
||||||
use crate::evaluation_context::EvaluationContext;
|
|
||||||
use crate::example::Example;
|
use crate::example::Example;
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_parser::ParserScope;
|
use nu_parser::ParserScope;
|
||||||
@ -32,7 +31,7 @@ pub trait WholeStreamCommand: Send + Sync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run(&self, args: CommandArgs) -> Result<InputStream, ShellError> {
|
fn run(&self, args: CommandArgs) -> Result<InputStream, ShellError> {
|
||||||
let context = EvaluationContext::from_args(&args);
|
let context = args.context.clone();
|
||||||
let stream = self.run_with_actions(args)?;
|
let stream = self.run_with_actions(args)?;
|
||||||
|
|
||||||
Ok(Box::new(crate::evaluate::internal::InternalIterator {
|
Ok(Box::new(crate::evaluate::internal::InternalIterator {
|
||||||
@ -81,7 +80,7 @@ impl WholeStreamCommand for Arc<Block> {
|
|||||||
|
|
||||||
let external_redirection = args.call_info.args.external_redirection;
|
let external_redirection = args.call_info.args.external_redirection;
|
||||||
|
|
||||||
let ctx = EvaluationContext::from_args(&args);
|
let ctx = &args.context;
|
||||||
let evaluated = call_info.evaluate(&ctx)?;
|
let evaluated = call_info.evaluate(&ctx)?;
|
||||||
|
|
||||||
let input = args.input;
|
let input = args.input;
|
||||||
|
Loading…
Reference in New Issue
Block a user