2
0
Fork 0
mirror of https://github.com/nushell/nushell synced 2025-02-13 12:43:48 +00:00
nushell/tests
Devyn Cairns 91d44f15c1
Allow plugins to report their own version and store it in the registry ()
# Description

This allows plugins to report their version (and potentially other
metadata in the future). The version is shown in `plugin list` and in
`version`.

The metadata is stored in the registry file, and reflects whatever was
retrieved on `plugin add`, not necessarily the running binary. This can
help you to diagnose if there's some kind of mismatch with what you
expect. We could potentially use this functionality to show a warning or
error if a plugin being run does not have the same version as what was
in the cache file, suggesting `plugin add` be run again, but I haven't
done that at this point.

It is optional, and it requires the plugin author to make some code
changes if they want to provide it, since I can't automatically
determine the version of the calling crate or anything tricky like that
to do it.

Example:

```
> plugin list | select name version is_running pid
╭───┬────────────────┬─────────┬────────────┬─────╮
│ # │      name      │ version │ is_running │ pid │
├───┼────────────────┼─────────┼────────────┼─────┤
│ 0 │ example        │ 0.93.1  │ false      │     │
│ 1 │ gstat          │ 0.93.1  │ false      │     │
│ 2 │ inc            │ 0.93.1  │ false      │     │
│ 3 │ python_example │ 0.1.0   │ false      │     │
╰───┴────────────────┴─────────┴────────────┴─────╯
```

cc @maxim-uvarov (he asked for it)

# User-Facing Changes

- `plugin list` gets a `version` column
- `version` shows plugin versions when available
- plugin authors *should* add `fn metadata()` to their `impl Plugin`,
but don't have to

# Tests + Formatting

Tested the low level stuff and also the `plugin list` column.

# After Submitting
- [ ] update plugin guide docs
- [ ] update plugin protocol docs (`Metadata` call & response)
- [ ] update plugin template (`fn metadata()` should be easy)
- [ ] release notes
2024-06-21 06:27:09 -05:00
..
assets/nu_json Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
const_ add raw-string literal support () 2024-05-02 09:36:37 -04:00
eval Exit early when encountering parsing errors () 2023-09-05 14:36:37 +02:00
fixtures add some completion tests () 2024-05-23 10:47:06 +08:00
hooks Fix hooks on 0.92.0 () 2024-04-04 09:25:54 +02:00
modules Avoid taking unnecessary ownership of intermediates () 2024-05-04 00:53:15 +00:00
overlays Avoid taking unnecessary ownership of intermediates () 2024-05-04 00:53:15 +00:00
parsing Avoid taking unnecessary ownership of intermediates () 2024-05-04 00:53:15 +00:00
path Avoid taking unnecessary ownership of intermediates () 2024-05-04 00:53:15 +00:00
plugin_persistence Allow plugins to report their own version and store it in the registry () 2024-06-21 06:27:09 -05:00
plugins Allow plugins to report their own version and store it in the registry () 2024-06-21 06:27:09 -05:00
repl Rewrite run_external.rs () 2024-05-23 02:05:27 +00:00
scope Avoid taking unnecessary ownership of intermediates () 2024-05-04 00:53:15 +00:00
shell Make which-support feature non-optional () 2024-06-12 20:04:12 -05:00
main.rs Merged tests to produce a single binary () 2024-05-13 13:37:53 +00:00