mirror of
https://github.com/nushell/nushell.git
synced 2025-03-09 21:21:25 +01: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
75 lines
1.6 KiB
Rust
75 lines
1.6 KiB
Rust
use crate::*;
|
|
use nu_protocol::engine::{EngineState, StateWorkingSet};
|
|
|
|
pub fn create_default_context() -> EngineState {
|
|
let mut engine_state = EngineState::new();
|
|
|
|
let delta = {
|
|
let mut working_set = StateWorkingSet::new(&engine_state);
|
|
|
|
macro_rules! bind_command {
|
|
( $( $command:expr ),* $(,)? ) => {
|
|
$( working_set.add_decl(Box::new($command)); )*
|
|
};
|
|
}
|
|
|
|
// Core
|
|
bind_command! {
|
|
Alias,
|
|
Break,
|
|
Collect,
|
|
Const,
|
|
Continue,
|
|
Def,
|
|
Describe,
|
|
Do,
|
|
Echo,
|
|
ErrorMake,
|
|
ExportAlias,
|
|
ExportCommand,
|
|
ExportConst,
|
|
ExportDef,
|
|
ExportExtern,
|
|
ExportUse,
|
|
ExportModule,
|
|
Extern,
|
|
For,
|
|
Hide,
|
|
HideEnv,
|
|
If,
|
|
Ignore,
|
|
Overlay,
|
|
OverlayUse,
|
|
OverlayList,
|
|
OverlayNew,
|
|
OverlayHide,
|
|
LazyMake,
|
|
Let,
|
|
Loop,
|
|
Match,
|
|
Module,
|
|
Mut,
|
|
Return,
|
|
Scope,
|
|
ScopeAliases,
|
|
ScopeCommands,
|
|
ScopeEngineStats,
|
|
ScopeExterns,
|
|
ScopeModules,
|
|
ScopeVariables,
|
|
Try,
|
|
Use,
|
|
Version,
|
|
While,
|
|
};
|
|
|
|
working_set.render()
|
|
};
|
|
|
|
if let Err(err) = engine_state.merge_delta(delta) {
|
|
eprintln!("Error creating default context: {err:?}");
|
|
}
|
|
|
|
engine_state
|
|
}
|