nushell/tests
Devyn Cairns f3843a6176
Make plugins able to find and call other commands (#13407)
# Description

Adds functionality to the plugin interface to support calling internal
commands from plugins. For example, using `view ir --json`:

```rust
let closure: Value = call.req(0)?;

let Some(decl_id) = engine.find_decl("view ir")? else {
    return Err(LabeledError::new("`view ir` not found"));
};

let ir_json = engine.call_decl(
    decl_id,
    EvaluatedCall::new(call.head)
        .with_named("json".into_spanned(call.head), Value::bool(true, call.head))
        .with_positional(closure),
    PipelineData::Empty,
    true,
    false,
)?.into_value()?.into_string()?;

let ir = serde_json::from_value(&ir_json);

// ...
```

# User-Facing Changes

Plugin developers can now use `EngineInterface::find_decl()` and
`call_decl()` to call internal commands, which could be handy for
formatters like `to csv` or `to nuon`, or for reflection commands that
help gain insight into the engine.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
- [ ] release notes
- [ ] update plugin protocol documentation: `FindDecl`, `CallDecl`
engine calls; `Identifier` engine call response
2024-07-19 13:54:21 +08:00
..
assets/nu_json Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
const_ add raw-string literal support (#9956) 2024-05-02 09:36:37 -04:00
eval Internal representation (IR) compiler and evaluator (#13330) 2024-07-10 17:33:59 -07:00
fixtures Force completers to sort in fetch() (#13242) 2024-07-03 06:48:06 -05:00
hooks Fix hooks on 0.92.0 (#12383) 2024-04-04 09:25:54 +02:00
modules Enable reloading changes to a submodule (#13170) 2024-06-25 18:33:37 -07:00
overlays Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
parsing Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
path Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
plugin_persistence Allow plugins to report their own version and store it in the registry (#12883) 2024-06-21 06:27:09 -05:00
plugins Make plugins able to find and call other commands (#13407) 2024-07-19 13:54:21 +08:00
repl Overhaul $in expressions (#13357) 2024-07-17 16:02:42 -05:00
scope Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
shell Make pipe redirections consistent, add err>| etc. forms (#13334) 2024-07-11 07:16:22 +08:00
main.rs Merged tests to produce a single binary (#12826) 2024-05-13 13:37:53 +00:00