nushell/crates/nu-protocol/src
Devyn Cairns 1f4131532d
Deprecate register and add plugin use (#12607)
# Description

Adds a new keyword, `plugin use`. Unlike `register`, this merely loads
the signatures from the plugin cache file. The file is configurable with
the `--plugin-config` option either to `nu` or to `plugin use` itself,
just like the other `plugin` family of commands. At the REPL, one might
do this to replace `register`:

```nushell
> plugin add ~/.cargo/bin/nu_plugin_foo
> plugin use foo
```

This will not work in a script, because `plugin use` is a keyword and
`plugin add` does not evaluate at parse time (intentionally). This means
we no longer run random binaries during parse.

The `--plugins` option has been added to allow running `nu` with certain
plugins in one step. This is used especially for the `nu_with_plugins!`
test macro, but I'd imagine is generally useful. The only weird quirk is
that it has to be a list, and we don't really do this for any of our
other CLI args at the moment.

`register` now prints a deprecation parse warning.

This should fix #11923, as we now have a complete alternative to
`register`.

# User-Facing Changes

- Add `plugin use` command
- Deprecate `register`
- Add `--plugins` option to `nu` to replace a common use of `register`

# Tests + Formatting

I think I've tested it thoroughly enough and every existing test passes.
Testing nu CLI options and alternate config files is a little hairy and
I wish there were some more generic helpers for this, so this will go on
my TODO list for refactoring.

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting

- [ ] Update plugins sections of book
- [ ] Release notes
2024-04-23 06:37:50 -05:00
..
ast Deprecate register and add plugin use (#12607) 2024-04-23 06:37:50 -05:00
config Remove the Value::Block case (#12582) 2024-04-21 07:03:33 +02:00
debugger Add ListItem type for Expr::List (#12529) 2024-04-18 13:21:05 +02:00
engine Overhaul the plugin cache file with a new msgpack+brotli format (#12579) 2024-04-21 07:36:26 -05:00
errors Deprecate register and add plugin use (#12607) 2024-04-23 06:37:50 -05:00
pipeline_data Rename IoStream to OutDest (#12433) 2024-04-09 16:48:32 +00:00
plugin Deprecate register and add plugin use (#12607) 2024-04-23 06:37:50 -05:00
value Remove the Value::Block case (#12582) 2024-04-21 07:03:33 +02:00
alias.rs IO and redirection overhaul (#11934) 2024-03-14 15:51:55 -05:00
did_you_mean.rs Improve case insensitivity consistency (#10884) 2023-11-08 23:58:54 +01:00
eval_base.rs Remove the Value::Block case (#12582) 2024-04-21 07:03:33 +02:00
eval_const.rs Overhaul the plugin cache file with a new msgpack+brotli format (#12579) 2024-04-21 07:36:26 -05:00
example.rs Overhaul the plugin cache file with a new msgpack+brotli format (#12579) 2024-04-21 07:36:26 -05:00
id.rs Add virtual path abstraction layer (#9245) 2023-05-23 23:48:50 +03:00
lev_distance.rs Suggest existing variables on not found (#8902) 2023-05-02 18:17:14 +03:00
lib.rs Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
module.rs Error on use path item1 item2, if item1 is not a module (#11183) 2023-12-05 11:38:45 +01:00
signature.rs Overhaul the plugin cache file with a new msgpack+brotli format (#12579) 2024-04-21 07:36:26 -05:00
span.rs Add ErrSpan extension trait for Result (#12626) 2024-04-23 10:39:55 +02:00
syntax_shape.rs open, rm, umv, cp, rm and du: Don't globs if inputs are variables or string interpolation (#11886) 2024-02-23 09:17:09 +08:00
ty.rs Glob: don't allow implicit casting between glob and string (#11992) 2024-02-28 23:05:35 +08:00
util.rs Convert more ShellError variants to named fields (#11173) 2023-11-28 06:43:51 -06:00