nushell/crates/nu-cmd-lang/src/default_context.rs
Ian Manske 847646e44e
Remove lazy records (#12682)
# Description
Removes lazy records from the language, following from the reasons
outlined in #12622. Namely, this should make semantics more clear and
will eliminate concerns regarding maintainability.

# User-Facing Changes
- Breaking change: `lazy make` is removed.
- Breaking change: `describe --collect-lazyrecords` flag is removed.
- `sys` and `debug info` now return regular records.

# After Submitting
- Update nushell book if necessary.
- Explore new `sys` and `debug info` APIs to prevent them from taking
too long (e.g., subcommands or taking an optional column/cell-path
argument).
2024-05-03 08:36:10 +08:00

74 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,
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
}