nu_cmd_plugin/
default_context.rs1use crate::*;
2use nu_protocol::engine::{EngineState, StateWorkingSet};
3
4pub fn add_plugin_command_context(mut engine_state: EngineState) -> EngineState {
5 let delta = {
6 let mut working_set = StateWorkingSet::new(&engine_state);
7
8 macro_rules! bind_command {
9 ( $( $command:expr ),* $(,)? ) => {
10 $( working_set.add_decl(Box::new($command)); )*
11 };
12 }
13
14 bind_command!(
15 PluginAdd,
16 PluginCommand,
17 PluginList,
18 PluginRm,
19 PluginStop,
20 PluginUse,
21 );
22
23 working_set.render()
24 };
25
26 if let Err(err) = engine_state.merge_delta(delta) {
27 eprintln!("Error creating default context: {err:?}");
28 }
29
30 engine_state
31}