nushell/crates/nu-explore/src/default_context.rs
Stefan Holderbach 604aadc938
Move explore command out of nu-command deps (#9421)
# Description
For better parallel compilation, make sure that `nu-command` doesn't
depend on `nu-explore`.

Moves the `nu_protocol::Command` implementation into `nu-explore`. Adds
`nu_explore::add_explore_context()` which is used in `main.rs` to add
the `explore` command.

Minor improvement in compile time ~0.5 sec observed as `nu-command`
still blocks on `nu-cmd-lang` as well.

## `cargo build --timings` before


![grafik](https://github.com/nushell/nushell/assets/15833959/583aa56e-6a1e-47b9-ba00-6a86293a38db)

## `cargo build --timings` after


![grafik](https://github.com/nushell/nushell/assets/15833959/30687575-c1c8-4635-bcdd-7ce9488fcfff)


# User-Facing Changes
None
2023-06-14 01:18:36 +02:00

18 lines
480 B
Rust

use nu_protocol::engine::{EngineState, StateWorkingSet};
use crate::explore::*;
pub fn add_explore_context(mut engine_state: EngineState) -> EngineState {
let delta = {
let mut working_set = StateWorkingSet::new(&engine_state);
working_set.add_decl(Box::new(Explore));
working_set.render()
};
if let Err(err) = engine_state.merge_delta(delta) {
eprintln!("Error creating explore command context: {err:?}");
}
engine_state
}