mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:15:53 +02:00
Break up interdependencies of command crates (#9429)
# 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  ### after  # 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)
This commit is contained in:
committed by
GitHub
parent
b14bdd865f
commit
46eebc644c
@ -1,9 +1,12 @@
|
||||
mod bits;
|
||||
|
||||
use nu_protocol::engine::StateWorkingSet;
|
||||
use nu_protocol::engine::{EngineState, StateWorkingSet};
|
||||
|
||||
pub fn add_extra_decls(working_set: &mut StateWorkingSet) {
|
||||
macro_rules! bind_command {
|
||||
pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState {
|
||||
let delta = {
|
||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
||||
|
||||
macro_rules! bind_command {
|
||||
( $command:expr ) => {
|
||||
working_set.add_decl(Box::new($command));
|
||||
};
|
||||
@ -12,15 +15,23 @@ pub fn add_extra_decls(working_set: &mut StateWorkingSet) {
|
||||
};
|
||||
}
|
||||
|
||||
bind_command!(
|
||||
bits::bits_::Bits,
|
||||
bits::and::BitsAnd,
|
||||
bits::not::BitsNot,
|
||||
bits::or::BitsOr,
|
||||
bits::xor::BitsXor,
|
||||
bits::rotate_left::BitsRol,
|
||||
bits::rotate_right::BitsRor,
|
||||
bits::shift_left::BitsShl,
|
||||
bits::shift_right::BitsShr
|
||||
);
|
||||
bind_command!(
|
||||
bits::bits_::Bits,
|
||||
bits::and::BitsAnd,
|
||||
bits::not::BitsNot,
|
||||
bits::or::BitsOr,
|
||||
bits::xor::BitsXor,
|
||||
bits::rotate_left::BitsRol,
|
||||
bits::rotate_right::BitsRor,
|
||||
bits::shift_left::BitsShl,
|
||||
bits::shift_right::BitsShr
|
||||
);
|
||||
working_set.render()
|
||||
};
|
||||
|
||||
if let Err(err) = engine_state.merge_delta(delta) {
|
||||
eprintln!("Error creating extra command context: {err:?}");
|
||||
}
|
||||
|
||||
engine_state
|
||||
}
|
||||
|
Reference in New Issue
Block a user