Split blocks and closures (#7075)

* Split closures and blocks

* Tests mostly working

* finish last fixes, passes all tests

* fmt
This commit is contained in:
JT
2022-11-10 21:21:49 +13:00
committed by GitHub
parent 921a66554e
commit 63433f1bc8
57 changed files with 576 additions and 220 deletions

View File

@ -6,7 +6,7 @@ use std::time::Duration;
use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
use nu_engine::{current_dir, eval_block, CallExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{CaptureBlock, Command, EngineState, Stack, StateWorkingSet};
use nu_protocol::engine::{Closure, Command, EngineState, Stack, StateWorkingSet};
use nu_protocol::{
format_error, Category, Example, IntoPipelineData, PipelineData, ShellError, Signature,
Spanned, SyntaxShape, Value,
@ -35,7 +35,7 @@ impl Command for Watch {
fn signature(&self) -> nu_protocol::Signature {
Signature::build("watch")
.required("path", SyntaxShape::Filepath, "the path to watch. Can be a file or directory")
.required("block", SyntaxShape::Block(None), "A Nu block of code to run whenever a file changes. The block will be passed `operation`, `path`, and `new_path` (for renames only) arguments in that order")
.required("block", SyntaxShape::Block, "A Nu block of code to run whenever a file changes. The block will be passed `operation`, `path`, and `new_path` (for renames only) arguments in that order")
.named(
"debounce-ms",
SyntaxShape::Int,
@ -82,7 +82,7 @@ impl Command for Watch {
}
};
let capture_block: CaptureBlock = call.req(engine_state, stack, 1)?;
let capture_block: Closure = call.req(engine_state, stack, 1)?;
let block = engine_state
.clone()
.get_block(capture_block.block_id)