New "display_output" hook. (#6915)

* New "display_output" hook.

* Fix unrelated "clippy" complaint in nu-tables crate.

* Fix code-formattng and style issues in "display_output" hook

* Enhance eval_hook to return PipelineData.

This allows a hook (including display_output) to return a value.

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
This commit is contained in:
Per Bothner
2022-11-05 17:46:40 -07:00
committed by GitHub
parent b90d701f89
commit beec658872
5 changed files with 106 additions and 43 deletions

View File

@@ -176,7 +176,7 @@ pub fn nu_repl() {
// Check for pre_prompt hook
let config = engine_state.get_config();
if let Some(hook) = config.hooks.pre_prompt.clone() {
if let Err(err) = eval_hook(&mut engine_state, &mut stack, vec![], &hook) {
if let Err(err) = eval_hook(&mut engine_state, &mut stack, None, vec![], &hook) {
outcome_err(&engine_state, &err);
}
}
@@ -194,7 +194,7 @@ pub fn nu_repl() {
// Check for pre_execution hook
let config = engine_state.get_config();
if let Some(hook) = config.hooks.pre_execution.clone() {
if let Err(err) = eval_hook(&mut engine_state, &mut stack, vec![], &hook) {
if let Err(err) = eval_hook(&mut engine_state, &mut stack, None, vec![], &hook) {
outcome_err(&engine_state, &err);
}
}