mirror of
https://github.com/nushell/nushell
synced 2025-01-06 18:29:02 +00:00
46eebc644c
# Description Make sure that our different crates that contain commands can be compiled in parallel. This can under certain circumstances accelerate the compilation with sufficient multithreading available. ## Details - Move `help` commands from `nu-cmd-lang` back to `nu-command` - This also makes sense as the commands are implemented in an ANSI-terminal specific way - Make `nu-cmd-lang` only a dev dependency for `nu-command` - Change context creation helpers for `nu-cmd-extra` and `nu-cmd-dataframe` to have a consistent api used in `src/main.rs`:`get_engine_state()` - `nu-command` now indepedent from `nu-cmd-extra` and `nu-cmd-dataframe` that are now dependencies of `nu` directly. (change to internal features) - Fix tests that previously used `nu-command::create_default_context()` with replacement functions ## From scratch compilation times: just debug (dev) build and default features ``` cargo clean --profile dev && cargo build --timings ``` ### before ![grafik](https://github.com/nushell/nushell/assets/15833959/e49f1f42-2e53-4a6c-bc23-625b686af1bc) ### after ![grafik](https://github.com/nushell/nushell/assets/15833959/8dec4723-e625-4a86-b91e-e6e808f64726) # User-Facing Changes None direct, only change to compilation on multithreaded jobs expected. # Tests + Formatting Tests that previously chose to use `nu-command` for their scope will still use `nu-cmd-lang` + `nu-command` (command list in the granularity at the time)
72 lines
1.5 KiB
Rust
72 lines
1.5 KiB
Rust
use nu_protocol::engine::{EngineState, StateWorkingSet};
|
|
|
|
use crate::*;
|
|
|
|
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,
|
|
DefEnv,
|
|
Describe,
|
|
Do,
|
|
Echo,
|
|
ErrorMake,
|
|
ExportAlias,
|
|
ExportCommand,
|
|
ExportDef,
|
|
ExportDefEnv,
|
|
ExportExtern,
|
|
ExportUse,
|
|
ExportModule,
|
|
Extern,
|
|
For,
|
|
Hide,
|
|
HideEnv,
|
|
If,
|
|
Ignore,
|
|
Overlay,
|
|
OverlayUse,
|
|
OverlayList,
|
|
OverlayNew,
|
|
OverlayHide,
|
|
LazyMake,
|
|
Let,
|
|
Loop,
|
|
Match,
|
|
Module,
|
|
Mut,
|
|
Return,
|
|
Try,
|
|
Use,
|
|
Version,
|
|
While,
|
|
};
|
|
|
|
//#[cfg(feature = "plugin")]
|
|
bind_command!(Register);
|
|
|
|
working_set.render()
|
|
};
|
|
|
|
if let Err(err) = engine_state.merge_delta(delta) {
|
|
eprintln!("Error creating default context: {err:?}");
|
|
}
|
|
|
|
engine_state
|
|
}
|