nushell/crates/nu-cmd-lang/src/core_commands
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
..
overlay Make get_full_help take &dyn Command (#12903) 2024-05-19 19:56:33 +02:00
scope Make get_full_help take &dyn Command (#12903) 2024-05-19 19:56:33 +02:00
alias.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
break_.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
collect.rs collect: don't require a closure (#12788) 2024-05-17 18:46:03 +02:00
const_.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
continue_.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
def.rs Fix multiple issues with def --wrapped help example (#13123) 2024-06-10 19:12:54 -05:00
describe.rs Add string/binary type color to ByteStream (#12897) 2024-05-20 00:35:32 +00:00
do_.rs Do example (#13190) 2024-06-20 18:46:56 -05:00
echo.rs Mention print in the echo help text (#12436) 2024-04-06 20:24:00 -05:00
error_make.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
export_alias.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
export_const.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
export_def.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
export_extern.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
export_module.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
export_use.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
export.rs Make get_full_help take &dyn Command (#12903) 2024-05-19 19:56:33 +02:00
extern_.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
for_.rs Deprecate --numbered from for (#13112) 2024-06-10 03:01:22 +00:00
hide_env.rs nu-cmd-lang cleanup (#12609) 2024-04-25 14:16:12 +00:00
hide.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
if_.rs Added search terms to if (#13145) 2024-06-13 19:55:17 -05:00
ignore.rs Rename IoStream to OutDest (#12433) 2024-04-09 16:48:32 +00:00
let_.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
loop_.rs Replace ExternalStream with new ByteStream type (#12774) 2024-05-16 07:11:18 -07:00
match_.rs nu-cmd-lang cleanup (#12609) 2024-04-25 14:16:12 +00:00
mod.rs Remove lazy records (#12682) 2024-05-03 08:36:10 +08:00
module.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
mut_.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
return_.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
try_.rs update try command's help (#13173) 2024-06-18 13:48:06 -05:00
use_.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
version.rs Allow plugins to report their own version and store it in the registry (#12883) 2024-06-21 06:27:09 -05:00
while_.rs Replace ExternalStream with new ByteStream type (#12774) 2024-05-16 07:11:18 -07:00