Add --execute option (#6302)

This commit is contained in:
Ariel Cohen
2022-08-18 12:25:52 +03:00
committed by GitHub
parent 4bbdb73668
commit df3b6d9d26
2 changed files with 25 additions and 2 deletions

View File

@ -16,7 +16,7 @@ use nu_protocol::{
ast::PathMember,
engine::{EngineState, Stack, StateWorkingSet},
format_duration, BlockId, HistoryFileFormat, PipelineData, PositionalArg, ShellError, Span,
Type, Value, VarId,
Spanned, Type, Value, VarId,
};
use reedline::{DefaultHinter, Emacs, SqliteBackedHistory, Vi};
use std::io::{self, Write};
@ -39,6 +39,7 @@ pub fn evaluate_repl(
stack: &mut Stack,
nushell_path: &str,
is_perf_true: bool,
prerun_command: Option<Spanned<String>>,
) -> Result<()> {
use reedline::{FileBackedHistory, Reedline, Signal};
@ -140,6 +141,17 @@ pub fn evaluate_repl(
}
}
if let Some(s) = prerun_command {
eval_source(
engine_state,
stack,
s.item.as_bytes(),
&format!("entry #{}", entry_num),
PipelineData::new(Span::new(0, 0)),
);
engine_state.merge_env(stack, get_guaranteed_cwd(engine_state, stack))?;
}
loop {
if is_perf_true {
info!(