nu_cli/commands/
default_context.rs

1use crate::commands::*;
2use nu_protocol::engine::{EngineState, StateWorkingSet};
3
4pub fn add_cli_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            Commandline,
16            CommandlineEdit,
17            CommandlineGetCursor,
18            CommandlineSetCursor,
19            History,
20            HistoryImport,
21            HistorySession,
22            Keybindings,
23            KeybindingsDefault,
24            KeybindingsList,
25            KeybindingsListen,
26        };
27
28        working_set.render()
29    };
30
31    if let Err(err) = engine_state.merge_delta(delta) {
32        eprintln!("Error creating CLI command context: {err:?}");
33    }
34
35    engine_state
36}