nushell/crates/nu-cli/src
Devyn Cairns 91d44f15c1
Allow plugins to report their own version and store it in the registry (#12883)
# 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
..
commands Make get_full_help take &dyn Command (#12903) 2024-05-19 19:56:33 +02:00
completions Fix the colors when completing using a relative path (#12898) 2024-06-07 08:07:23 -05:00
menus Make get_full_help take &dyn Command (#12903) 2024-05-19 19:56:33 +02:00
config_files.rs Allow plugins to report their own version and store it in the registry (#12883) 2024-06-21 06:27:09 -05:00
eval_cmds.rs Change the error style during tests to plain (#13061) 2024-06-18 21:37:24 -07:00
eval_file.rs Replace ExternalStream with new ByteStream type (#12774) 2024-05-16 07:11:18 -07:00
lib.rs Change the error style during tests to plain (#13061) 2024-06-18 21:37:24 -07:00
nu_highlight.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
print.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
prompt_update.rs Refactor the CLI code a bit (#12782) 2024-05-10 07:29:27 +08:00
prompt.rs cleanup osc calls for shell_integration (#12810) 2024-05-08 13:34:04 -05:00
reedline_config.rs Fix delta not being merged when evaluating menus (#13120) 2024-06-10 22:33:22 +03:00
repl.rs fixes a bug in OSC9;9 execution (#12994) 2024-05-29 18:06:47 -05:00
syntax_highlight.rs Move most of the peculiar argument handling for external calls into the parser (#13089) 2024-06-19 21:00:03 -07:00
util.rs Add string/binary type color to ByteStream (#12897) 2024-05-20 00:35:32 +00:00
validation.rs Remove old alias implementation (#8797) 2023-04-07 21:09:38 +03:00