mirror of
https://github.com/nushell/nushell.git
synced 2025-06-07 02:26:52 +02:00
# Description - Plugin signatures are now saved to `plugin.msgpackz`, which is brotli-compressed MessagePack. - The file is updated incrementally, rather than writing all plugin commands in the engine every time. - The file always contains the result of the `Signature` call to the plugin, even if commands were removed. - Invalid data for a particular plugin just causes an error to be reported, but the rest of the plugins can still be parsed # User-Facing Changes - The plugin file has a different filename, and it's not a nushell script. - The default `plugin.nu` file will be automatically migrated the first time, but not other plugin config files. - We don't currently provide any utilities that could help edit this file, beyond `plugin add` and `plugin rm` - `from msgpackz`, `to msgpackz` could also help - New commands: `plugin add`, `plugin rm` # Tests + Formatting Tests added for the format and for the invalid handling. - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] Check for documentation changes - [ ] Definitely needs release notes
22 lines
642 B
Rust
22 lines
642 B
Rust
use crate::{PluginExample, Signature};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// A simple wrapper for Signature that includes examples.
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
pub struct PluginSignature {
|
|
pub sig: Signature,
|
|
pub examples: Vec<PluginExample>,
|
|
}
|
|
|
|
impl PluginSignature {
|
|
pub fn new(sig: Signature, examples: Vec<PluginExample>) -> Self {
|
|
Self { sig, examples }
|
|
}
|
|
|
|
/// Build an internal signature with default help option
|
|
pub fn build(name: impl Into<String>) -> PluginSignature {
|
|
let sig = Signature::new(name.into()).add_help();
|
|
Self::new(sig, vec![])
|
|
}
|
|
}
|