nushell/crates/nu-parser/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
..
deparse.rs update deps calamine and quick-xml (#11582) 2024-01-19 12:23:51 -06:00
exportable.rs Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
flatten.rs Move most of the peculiar argument handling for external calls into the parser (#13089) 2024-06-19 21:00:03 -07:00
known_external.rs Span ID Refactor - Step 1 (#12960) 2024-06-05 09:57:14 +08:00
lex.rs make better messages for incomplete string (#12868) 2024-05-15 01:14:11 +00:00
lib.rs IO and redirection overhaul (#11934) 2024-03-14 15:51:55 -05:00
lite_parser.rs Fix panic when redirecting nothing (#12970) 2024-05-27 10:03:06 +08:00
parse_keywords.rs Allow plugins to report their own version and store it in the registry (#12883) 2024-06-21 06:27:09 -05:00
parse_patterns.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
parse_shape_specs.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
parser_path.rs Deprecate register and add plugin use (#12607) 2024-04-23 06:37:50 -05:00
parser.rs Move most of the peculiar argument handling for external calls into the parser (#13089) 2024-06-19 21:00:03 -07:00
type_check.rs Span ID Refactor - Step 1 (#12960) 2024-06-05 09:57:14 +08:00